OpenStack dynamic inventory

17 views
Skip to first unread message

Soufiane Benmalek

unread,
Apr 11, 2017, 11:32:41 AM4/11/17
to Ansible Project
Hi,

I developed an Ansible playbook to launch an instance on OpenStack.
I have this block:

---
- name: launch an instance
  hosts: localhost
  gather_facts: false
  tasks:
  - name: launch an instance
    os_server:
         state: present
         auth:
           auth_url: https://auth.cloud.ovh.net/v2.0/
           username:  secret
           password: secret
           project_name: 7321722640570976
         region_name: SBG3
         name: mariadbserver-01
         image: CentOS 7
         state: present
         network: Ext-Net
         flavor: s1-2
         key_name: DBaaSOVHKey
         meta:
            hostname: mariadb
    register: newnode
 
  - name: Show Server's IP
    debug: var=newnode.openstack.public_v4 


#Here i want to add a section mariadbservers and add the public IP address to this section
  - name: Register the hosts in the inventory
    add_host:
      hostname: "{{ newnode.openstack.public_v4 }}}"
      group: "{{ mariadbservers }}"


I have this error:

fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'mariadbservers' is undefined\n\nThe error appears to have been in '/home/soufiane/DBaaS/ansible-role-dbaas/roles/novaserver/tasks/main.yml': line 28, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n  - name: Register the hosts in the inventory\n    ^ here\n"}
 ____________________


Any ideas
Reply all
Reply to author
Forward
0 new messages