From 9bb5fcc5bd34fd138062c646da808921422d0b7a Mon Sep 17 00:00:00 2001 From: Giulio Fidente Date: Wed, 6 Dec 2017 12:01:25 +0100 Subject: [PATCH] Consume NodeDataLookup in ceph-ansible Makes it possible to provide per-node variables to ceph-ansible using the NodeDataLookup parameter, the same consumed by the $roleExtraConfigPre resource for puppet hieradata. Change-Id: Ia23825aea938f6f9bcf536e35cad562a1b96c93b Closes-Bug: #1736707 Co-Authored-By: fulton@redhat.com (cherry picked from commit eda02c05d7b688d3b81321377bf4b32bfa5329bd) --- workbooks/ceph-ansible.yaml | 57 +++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/workbooks/ceph-ansible.yaml b/workbooks/ceph-ansible.yaml index 578712590..e87f65ac0 100644 --- a/workbooks/ceph-ansible.yaml +++ b/workbooks/ceph-ansible.yaml @@ -20,6 +20,7 @@ workflows: ANSIBLE_HOST_KEY_CHECKING: 'False' - ceph_ansible_extra_vars: {} - ceph_ansible_playbook: /usr/share/ceph-ansible/site-docker.yml.sample + - node_data_lookup: '{}' tags: - tripleo-common-managed tasks: @@ -46,15 +47,54 @@ workflows: mds_ips: <% env().get('service_ips', {}).get('ceph_mds_ctlplane_node_ips', []) %> rgw_ips: <% env().get('service_ips', {}).get('ceph_rgw_ctlplane_node_ips', []) %> client_ips: <% env().get('service_ips', {}).get('ceph_client_ctlplane_node_ips', []) %> + on-success: merge_ip_lists + merge_ip_lists: + publish: + ips_list: <% ($.mon_ips + $.osd_ips + $.mds_ips + $.rgw_ips + $.client_ips).toSet() %> on-success: set_fork_count set_fork_count: - publish: # unique list of all IPs: make each list a set, take unions and count - fork_count: <% min($.mon_ips.toSet().union($.osd_ips.toSet()).union($.mds_ips.toSet()).union($.rgw_ips.toSet()).union($.client_ips.toSet()).count(), 100) %> # don't use >100 forks + publish: + fork_count: <% min($.ips_list.count(), 100) %> # don't use >100 forks on-success: make_fetch_directory make_fetch_directory: action: tripleo.files.make_temp_dir publish: fetch_directory: <% task(make_fetch_directory).result.path %> + on-success: collect_nodes_uuid + collect_nodes_uuid: + action: tripleo.ansible-playbook + input: + inventory: + overcloud: + hosts: <% $.ips_list.toDict($, {}) %> + remote_user: tripleo-admin + become: true + become_user: root + verbosity: 0 + ssh_private_key: <% $.private_key %> + extra_env_variables: + ANSIBLE_HOST_KEY_CHECKING: 'False' + ANSIBLE_STDOUT_CALLBACK: 'json' + playbook: + - hosts: overcloud + gather_facts: no + tasks: + - name: collect machine id + command: dmidecode -s system-uuid + publish: + ansible_output: <% json_parse(task().result.stderr) %> + on-success: set_ip_uuids + set_ip_uuids: + publish: + ip_uuids: <% let(root => $.ansible_output.get('plays')[0].get('tasks')[0].get('hosts')) -> $.ips_list.toDict($, $root.get($).get('stdout')) %> + on-success: parse_node_data_lookup + parse_node_data_lookup: + publish: + json_node_data_lookup: <% json_parse($.node_data_lookup) %> + on-success: map_node_data_lookup + map_node_data_lookup: + publish: + ips_data: <% let(uuids => $.ip_uuids, root => $) -> $.ips_list.toDict($, $root.json_node_data_lookup.get($uuids.get($, "NO-UUID-FOUND"), {})) %> on-success: set_role_vars set_role_vars: publish: @@ -75,15 +115,17 @@ workflows: input: inventory: mons: - hosts: <% $.mon_ips.toDict($, {}) %> + hosts: <% let(root => $) -> $.mon_ips.toDict($, $root.ips_data.get($, {})) %> osds: - hosts: <% $.osd_ips.toDict($, {}) %> + hosts: <% let(root => $) -> $.osd_ips.toDict($, $root.ips_data.get($, {})) %> mdss: - hosts: <% $.mds_ips.toDict($, {}) %> + hosts: <% let(root => $) -> $.mds_ips.toDict($, $root.ips_data.get($, {})) %> rgws: - hosts: <% $.rgw_ips.toDict($, {}) %> + hosts: <% let(root => $) -> $.rgw_ips.toDict($, $root.ips_data.get($, {})) %> clients: - hosts: <% $.client_ips.toDict($, {}) %> + hosts: <% let(root => $) -> $.client_ips.toDict($, $root.ips_data.get($, {})) %> + all: + vars: <% $.extra_vars %> playbook: <% $.ceph_ansible_playbook %> remote_user: tripleo-admin become: true @@ -93,7 +135,6 @@ workflows: ssh_private_key: <% $.private_key %> skip_tags: <% $.ansible_skip_tags %> extra_env_variables: <% $.ansible_extra_env_variables %> - extra_vars: <% $.extra_vars %> publish: output: <% task(ceph_install).result %> on-complete: purge_fetch_directory