kolla-ansible/ansible/site.yml
Paul Bourke cf81958f66 Fix fact gathering when using --limit
If an operator wants to deploy a single node (e.g. add an additional
compute), they may want to use the --limit feature of Ansible to avoid
waiting for every play across every node.

The problem with this is that --limit will gather facts for that node
only, causing template errors such as the infamous ('dict object' has no
attribute u'ansible_eth0'").

Ansible has catered to this problem to an extent with it's
"delegate_facts" mechanism. The only problem is that in the default 'all
nodes' case, we end up with a storm of SSHs as each node SSHs to every
other. I'm solving this with a separate task to only use this mechanism
when a subset of nodes has been specified (see ansible_play_batch).

Useful links on this subject:
- https://medium.com/@george.shuklin/perfecting-forced-fact-gathering-in-ansible-1611f9c8d0d5#.tr5zs3e7x
- http://docs.ansible.com/ansible/playbooks_delegation.html#delegated-facts

Change-Id: Ibb691eae15cacd9e5129ae9280fd296f5ba95940
Closes-Bug: 1642004
2016-11-16 11:32:33 +00:00

415 lines
8.7 KiB
YAML

---
# NOTE(awiddersheim): Gather facts for all hosts as a
# first step since several plays below require them when
# building their configurations. The below 'gather_facts'
# set to 'false' is a bit confusing but this is to avoid
# Ansible gathering facts twice.
- name: Gather facts for all hosts
hosts: all
serial: '{{ serial|default("0") }}'
gather_facts: false
tasks:
- setup:
tags: always
# NOTE(pbourke): This case covers deploying subsets of hosts using --limit. The
# limit arg will cause the first play to gather facts only about that node,
# meaning facts such as IP addresses for rabbitmq nodes etc. will be undefined
# in the case of adding a single compute node.
# We don't want to add the delegate parameters to the above play as it will
# result in ((num_nodes-1)^2) number of SSHs when running for all nodes
# which can be very inefficient.
- name: Gather facts for all hosts (if using --limit)
hosts: all
serial: '{{ serial|default("0") }}'
gather_facts: false
tasks:
- setup:
delegate_facts: True
delegate_to: "{{ item }}"
with_items: "{{ groups['all'] }}"
when:
- (play_hosts | length) != (groups['all'] | length)
- hosts:
- all
roles:
- role: prechecks
when: action == "precheck"
- hosts:
- ceph-mon
- ceph-osd
- ceph-rgw
serial: '{{ serial|default("0") }}'
roles:
- { role: ceph,
tags: ceph,
when: enable_ceph | bool }
- hosts: collectd
serial: '{{ serial|default("0") }}'
roles:
- { role: collectd,
tags: collectd,
when: enable_collectd | bool }
- hosts: elasticsearch
serial: '{{ serial|default("0") }}'
roles:
- { role: elasticsearch,
tags: elasticsearch,
when: enable_elasticsearch | bool }
- hosts: influxdb
serial: '{{ serial|default("0") }}'
roles:
- { role: influxdb,
tags: influxdb,
when: enable_influxdb | bool }
- hosts:
- telegraf
serial: '{{ serial|default("0") }}'
roles:
- { role: telegraf,
tags: telegraf,
when: enable_telegraf | bool }
- hosts:
- haproxy
roles:
- { role: haproxy,
tags: haproxy,
when: enable_haproxy | bool }
- hosts: kibana
serial: '{{ serial|default("0") }}'
roles:
- { role: kibana,
tags: kibana,
when: enable_kibana | bool }
- hosts: memcached
serial: '{{ serial|default("0") }}'
roles:
- { role: memcached,
tags: [memcache, memcached],
when: enable_memcached | bool }
- hosts: mariadb
serial: '{{ serial|default("0") }}'
roles:
- { role: mariadb,
tags: mariadb,
when: enable_mariadb | bool }
- hosts:
- iscsid
- tgtd
serial: '{{ serial|default("0") }}'
roles:
- { role: iscsi,
tags: iscsi,
when: enable_iscsid | bool }
- hosts:
- multipathd
serial: '{{ serial|default("0") }}'
roles:
- { role: multipathd,
tags: multipathd,
when: enable_multipathd | bool }
- hosts: rabbitmq
roles:
- { role: rabbitmq,
tags: rabbitmq,
when: enable_rabbitmq | bool }
- hosts: etcd
serial: '{{ serial|default("0") }}'
roles:
- { role: etcd,
tags: etcd,
when: enable_etcd | bool }
- hosts:
- keystone
serial: '{{ serial|default("0") }}'
roles:
- { role: keystone,
tags: keystone,
when: enable_keystone | bool }
- hosts:
- swift-account-server
- swift-container-server
- swift-object-server
- swift-proxy-server
serial: '{{ serial|default("0") }}'
roles:
- { role: swift,
tags: swift,
when: enable_swift | bool }
- hosts:
- ceph-mon
- glance-api
- glance-registry
serial: '{{ serial|default("0") }}'
roles:
- { role: glance,
tags: glance,
when: enable_glance | bool }
- hosts:
- ironic-api
- ironic-conductor
- ironic-inspector
- ironic-pxe
serial: '{{ serial|default("0") }}'
roles:
- { role: ironic,
tags: ironic,
when: enable_ironic | bool }
- hosts:
- ceph-mon
- compute
- nova-api
- nova-conductor
- nova-consoleauth
- nova-novncproxy
- nova-scheduler
serial: '{{ serial|default("0") }}'
roles:
- { role: nova,
tags: nova,
when: enable_nova | bool }
- hosts:
- compute
roles:
- { role: kuryr,
tags: kuryr,
when: enable_kuryr | bool }
# (gmmaha): Please do not change the order listed here. The current order is a
# workaround to fix the bug https://bugs.launchpad.net/kolla/+bug/1546789
- hosts:
- neutron-server
- neutron-dhcp-agent
- neutron-l3-agent
- neutron-lbaas-agent
- neutron-metadata-agent
- neutron-vpnaas-agent
- compute
- manila-share
serial: '{{ serial|default("0") }}'
roles:
- { role: neutron,
tags: neutron,
when: enable_neutron | bool }
- hosts:
- ceph-mon
- cinder-api
- cinder-backup
- cinder-scheduler
- cinder-volume
serial: '{{ serial|default("0") }}'
roles:
- { role: cinder,
tags: cinder,
when: enable_cinder | bool }
- hosts:
- heat-api
- heat-api-cfn
- heat-engine
serial: '{{ serial|default("0") }}'
roles:
- { role: heat,
tags: heat,
when: enable_heat | bool }
- hosts:
- horizon
serial: '{{ serial|default("0") }}'
roles:
- { role: horizon,
tags: horizon,
when: enable_horizon | bool }
- hosts:
- murano-api
- murano-engine
serial: '{{ serial|default("0") }}'
roles:
- { role: murano,
tags: murano,
when: enable_murano | bool }
- hosts:
- magnum-api
- magnum-conductor
serial: '{{ serial|default("0") }}'
roles:
- { role: magnum,
tags: magnum,
when: enable_magnum | bool }
- hosts:
- mistral-api
- mistral-engine
- mistral-executor
serial: '{{ serial|default("0") }}'
roles:
- { role: mistral,
tags: mistral,
when: enable_mistral | bool }
- hosts:
- sahara-api
- sahara-engine
serial: '{{ serial|default("0") }}'
roles:
- { role: sahara,
tags: sahara,
when: enable_sahara | bool }
- hosts:
- mongodb
serial: '{{ serial|default("0") }}'
roles:
- { role: mongodb,
tags: mongodb,
when: enable_mongodb | bool }
- hosts:
- manila-api
- manila-data
- manila-share
- manila-scheduler
serial: '{{ serial|default("0") }}'
roles:
- { role: manila,
tags: manila,
when: enable_manila | bool }
- hosts:
- gnocchi-api
- gnocchi-metricd
- gnocchi-statsd
serial: '{{ serial|default("0") }}'
roles:
- { role: gnocchi,
tags: gnocchi,
when: enable_gnocchi | bool }
- hosts:
- ceilometer
- compute
serial: '{{ serial|default("0") }}'
roles:
- { role: ceilometer,
tags: ceilometer,
when: enable_ceilometer | bool }
- hosts:
- aodh
serial: '{{ serial|default("0") }}'
roles:
- { role: aodh,
tags: aodh,
when: enable_aodh | bool }
- hosts:
- barbican-api
- barbican-keystone-listener
- barbican-worker
serial: '{{ serial|default("0") }}'
roles:
- { role: barbican,
tags: barbican,
when: enable_barbican | bool }
- hosts:
- congress-api
- congress-policy-engine
- congress-datasource
serial: '{{ serial|default("0") }}'
roles:
- { role: congress,
tags: congress,
when: enable_congress | bool }
- hosts:
- tempest
serial: '{{ serial|default("0") }}'
roles:
- { role: tempest,
tags: tempest,
when: enable_tempest | bool }
- hosts: rally
serial: '{{ serial|default("0") }}'
roles:
- { role: rally,
tags: rally,
when: enable_rally | bool }
- hosts:
- vmtp
serial: '{{ serial|default("0") }}'
roles:
- { role: vmtp,
tags: vmtp,
when: enable_vmtp | bool }
- hosts:
- watcher-api
- watcher-engine
- watcher-applier
serial: '{{ serial|default("0") }}'
roles:
- { role: watcher,
tags: watcher,
when: enable_watcher | bool }
- hosts:
- grafana
serial: '{{ serial|default("0") }}'
roles:
- { role: grafana,
tags: grafana,
when: enable_grafana | bool }
- hosts:
- cloudkitty-api
- cloudkitty-processor
serial: '{{ serial|default("0") }}'
roles:
- { role: cloudkitty,
tags: cloudkitty,
when: enable_cloudkitty | bool }
- hosts:
- senlin-api
- senlin-engine
serial: '{{ serial|default("0") }}'
roles:
- { role: senlin,
tags: senlin,
when: enable_senlin | bool }
- hosts:
- searchlight-api
- searchlight-listener
serial: '{{ serial|default("0") }}'
roles:
- { role: searchlight,
tags: searchlight,
when: enable_searchlight | bool }