Hi,
I use Ansible to launch new servers on an OpenStack public cloud provider.
This is my playbook:
---
- 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: secret
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=item
with_items: openstack.instances
#newnode.openstack.public_v4
- name: Register the hosts in the inventory
add_host:
name: "{{ newnode.openstack.public_v4 }}"
group: "{{mariadbservers}}"
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"}
Problem:
Nothing is added
Any ideas
i want in /etc/ansible/hosts
[mariadbservers]
x.x.x.x