Ansible for Openstack

15 views
Skip to first unread message

Rahul Kumar

unread,
Jul 30, 2019, 4:26:48 AM7/30/19
to ansible...@googlegroups.com
Hi Team,
Currently I am trying to provision Openstack resources using Ansible with sample template snippet as below:
 os_server:
        state: present
        cloud: smscrhosp
        name: test-instance
        image: CentOS-7-x86_64-GenericCloud
        key_name: mariachi-pub-key
        timeout: 200
        flavor: m1.small
        network: test-network
        auto_ip: yes
        security_groups:\\\\\\\\

I want to know , if our topology needs 10 nodes , then do we need to write this os_server 10 times in Playbook
or is there any better way to achive same?
Rahul

Dick Visser

unread,
Jul 30, 2019, 7:36:59 AM7/30/19
to ansible...@googlegroups.com
Use a loop to repeat the task as many times as you need

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAGH8rEzWEkhCMvnM8E2DMv9m3oYJ-tPVTVdJR9HWCQ%2BsdFkeXw%40mail.gmail.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Rahul Kumar

unread,
Jul 31, 2019, 6:05:20 AM7/31/19
to ansible...@googlegroups.com
Hi All,
I am trying to create complete stack of Openstack as below snippet:
  os_server:
     name: "{{ prefix }}-{{ item.name }}"
     state: present
     key_name: "{{ item.key }}"
     availability_zone: "{{ item.availability_zone }}"
     nics: "{{ item.nics }}"
     image: "{{ item.image }}"
     flavor: "{{ item.flavor }}"
  with_items: "{{ servers }}"
  register: "os_hosts"

- name: Create Networks
  os_network:
    name: "{{ item.name }}"
    state: present
    external: false
    wait: yes
  with_items: "{{ networks }}"

I am trying to understand , how I can make dependencies of one task to another. For example in above example:
If network does not exist (with the specfified ID item.nics ), then create the one using 2nd task ? And since its mutlinetworks and multiserver mode, how we ensure that particular server is attached to particular network, does this needs to be taken care while defining those variables or anything else in playbook we can do?

Rahul
Reply all
Reply to author
Forward
0 new messages