Created
July 9, 2020 13:12
-
-
Save amarao/20690d7b73e7d96e05661fab775aa656 to your computer and use it in GitHub Desktop.
Dynamic provision in ansible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Creating instances for dynamic inventory | |
hosts: somegroup | |
gather_facts: false | |
tasks: | |
- name: Create VM | |
delegate_to: localhost | |
os_server: | |
name: '{{ instance_name }}' | |
auto_ip: false | |
flavor: '{{ flavor }}' | |
network: '{{ network }}' | |
state: present | |
image: '{{ image }}' | |
security_groups: ' | |
key_name: '{{ key_name }}' | |
register: vm_result | |
- name: Generating dynamic inventory | |
delegate_to: localhost | |
copy: | |
dest: '{{ dyn_inv }}/{{ inventory_hostname }}.yaml' | |
content: | | |
somegroup: | |
hosts: | |
'{{ inventory_hostname }}': | |
ansible_host: '{{ ip }}' | |
ansible_user: cloud-user | |
openstack_id: '{{ id }}' | |
openstack_instance_name: '{{ instance_name }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment