Ansible

Preparations

  • Prepare virtual environment
$ virtualenv .venv
$ source .venv/bin/activate
$ pip install ansible shade
  • Create a clouds.yml file (see Authentication chapter)

OpenStack modules

---
- hosts: localhost
  connection: local
  gather_facts: no

  tasks:
  - name: Start instance
    os_server:
      cloud: sample
      name: sample
      flavor: 1C-1GB-10GB
      image: "Ubuntu 16.04 (Xenial Xerus)"
      key_name: samplekey
      security_groups:
        - default
      floating_ip_pools: public
      delete_fip: yes
      state: present

Note

floating_ip_pools must be adjusted according to the domain used. Except in the domain default, the public pool is DOMAINNAME-public.

  • Start the playbook now

Inventory

External inventory script

$ wget https://raw.githubusercontent.com/ansible/ansible/stable-2.5/contrib/inventory/openstack.py
$ chmod +x openstack.py
  • View the inventory with ansible-inventory
$ ansible-inventory -i openstack.py --list
  • Use the inventory with ansible & ansible-playbook
$ ansible-playbook -i openstack.py [...]
  • Alternatively add an entry in the ansible.cfg
[defaults]
inventory = openstack.py