From cddac5f1e98ecc63e78b5224ff994816a12a0168 Mon Sep 17 00:00:00 2001 From: jkilpatr Date: Thu, 22 Sep 2016 15:28:13 -0400 Subject: [PATCH] Make metadata robust to missing services So currently if some optional openstack service is not installed metadata will fail when it tires to work on its config file. This commit adds in a check for the existance of each service config before running the gathering tasks. What might be a useful addition to this commit would be some logic for determining which services should never be missing and alerting the user. Change-Id: Ie360f062646cb5431de9ed21bd0dd193b84ddcda --- .../gather/roles/ceilometer/tasks/main.yml | 7 +++++++ ansible/gather/roles/cinder/tasks/main.yml | 7 +++++++ ansible/gather/roles/glance/tasks/main.yml | 21 ++++++++++--------- ansible/gather/roles/gnocchi/tasks/main.yml | 8 +++++++ ansible/gather/roles/heat/tasks/main.yml | 8 +++++++ ansible/gather/roles/keystone/tasks/main.yml | 8 +++++++ ansible/gather/roles/neutron/tasks/main.yml | 8 +++++++ ansible/gather/roles/nova/tasks/main.yml | 8 +++++++ .../install/roles/no-sshd-dns/tasks/main.yml | 6 ++++-- ...metal-virt-undercloud-tripleo-browbeat.yml | 6 ++++++ 10 files changed, 75 insertions(+), 12 deletions(-) diff --git a/ansible/gather/roles/ceilometer/tasks/main.yml b/ansible/gather/roles/ceilometer/tasks/main.yml index 9a2e5df8f..df5031fc3 100644 --- a/ansible/gather/roles/ceilometer/tasks/main.yml +++ b/ansible/gather/roles/ceilometer/tasks/main.yml @@ -2,13 +2,20 @@ # # Tasks to get ceilometer facts # +- name: Check that Ceilometer is installed + become: true + stat: path=/etc/ceilometer/ceilometer.conf + register: ceilometer_config - name: Parse Ceilometer config become: true shell: python /tmp/openstack-config-parser.py ceilometer /etc/ceilometer/ceilometer.conf /tmp/out.yml + when: ceilometer_config.stat.exists - name: Fetch output fetch: src=/tmp/out.yml dest=/tmp/out.yml flat=yes + when: ceilometer_config.stat.exists - name: Load configuration variables include_vars: /tmp/out.yml + when: ceilometer_config.stat.exists diff --git a/ansible/gather/roles/cinder/tasks/main.yml b/ansible/gather/roles/cinder/tasks/main.yml index 051485be5..b82a507a3 100644 --- a/ansible/gather/roles/cinder/tasks/main.yml +++ b/ansible/gather/roles/cinder/tasks/main.yml @@ -2,13 +2,20 @@ # # Tasks to get cinder facts # +- name: Check that Ceilometer is installed + become: true + stat: path=/etc/cinder/cinder.conf + register: cinder_config - name: Parse Cinder config become: true shell: python /tmp/openstack-config-parser.py cinder /etc/cinder/cinder.conf /tmp/out.yml + when: cinder_config.stat.exists - name: Fetch output fetch: src=/tmp/out.yml dest=/tmp/out.yml flat=yes + when: cinder_config.stat.exists - name: Load configuration variables include_vars: /tmp/out.yml + when: cinder_config.stat.exists diff --git a/ansible/gather/roles/glance/tasks/main.yml b/ansible/gather/roles/glance/tasks/main.yml index d7d2b3c68..1ce5c5104 100644 --- a/ansible/gather/roles/glance/tasks/main.yml +++ b/ansible/gather/roles/glance/tasks/main.yml @@ -3,18 +3,19 @@ # Tasks to get Glance facts # -- name: Parse Glance config +- name: Get config files for Glance + shell: "ls /etc/glance/*.conf" + register: glance_config + +- name: Parse Glance config files become: true - shell: python /tmp/openstack-config-parser.py glance {{ item }} /tmp/{{ item | basename }}.yml - with_fileglob: - - /etc/glance/*.conf + shell: "python /tmp/openstack-config-parser.py glance {{ item }} /tmp/{{ item | basename }}.yml" + with_items: "{{ glance_config.stdout_lines }}" - name: Fetch output - fetch: src=/tmp/{{ item | basename }}.yml dest=/tmp/{{ item | basename }}.yml flat=yes - with_fileglob: - - /etc/glance/*.conf + fetch: "src=/tmp/{{ item | basename }}.yml dest=/tmp/{{ item | basename }}.yml flat=yes" + with_items: "{{ glance_config.stdout_lines }}" - name: Load configuration variables - include_vars: /tmp/{{ item | basename }}.yml - with_fileglob: - - /etc/glance/*.conf + include_vars: "/tmp/{{ item | basename }}.yml" + with_items: "{{ glance_config.stdout_lines }}" diff --git a/ansible/gather/roles/gnocchi/tasks/main.yml b/ansible/gather/roles/gnocchi/tasks/main.yml index 31f430968..6574f6f00 100644 --- a/ansible/gather/roles/gnocchi/tasks/main.yml +++ b/ansible/gather/roles/gnocchi/tasks/main.yml @@ -3,12 +3,20 @@ # Tasks to get gnocchi config data # +- name: Check that Gnocchi is installed + become: true + stat: path=/etc/gnocchi/gnocchi.conf + register: gnocchi_config + - name: Parse Gnocchi config become: true shell: python /tmp/openstack-config-parser.py gnocchi /etc/gnocchi/gnocchi.conf /tmp/out.yml + when: gnocchi_config.stat.exists - name: Fetch output fetch: src=/tmp/out.yml dest=/tmp/out.yml flat=yes + when: gnocchi_config.stat.exists - name: Load configuration variables include_vars: /tmp/out.yml + when: gnocchi_config.stat.exists diff --git a/ansible/gather/roles/heat/tasks/main.yml b/ansible/gather/roles/heat/tasks/main.yml index 651028366..6f3030bc6 100644 --- a/ansible/gather/roles/heat/tasks/main.yml +++ b/ansible/gather/roles/heat/tasks/main.yml @@ -3,12 +3,20 @@ # Tasks to get heat facts # +- name: Check that Heat is installed + become: true + stat: path=/etc/heat/heat.conf + register: heat_config + - name: Parse Heat config become: true shell: python /tmp/openstack-config-parser.py heat /etc/heat/heat.conf /tmp/out.yml + when: heat_config.stat.exists - name: Fetch output fetch: src=/tmp/out.yml dest=/tmp/out.yml flat=yes + when: heat_config.stat.exists - name: Load configuration variables include_vars: /tmp/out.yml + when: heat_config.stat.exists diff --git a/ansible/gather/roles/keystone/tasks/main.yml b/ansible/gather/roles/keystone/tasks/main.yml index 5b614e2ed..ae6052a8f 100644 --- a/ansible/gather/roles/keystone/tasks/main.yml +++ b/ansible/gather/roles/keystone/tasks/main.yml @@ -3,15 +3,23 @@ # Tasks to set keystone facts # +- name: Check that Keystone is installed + become: true + stat: path=/etc/keystone/keystone.conf + register: keystone_config + - name: Parse Keystone config become: true shell: python /tmp/openstack-config-parser.py keystone /etc/keystone/keystone.conf /tmp/out.yml + when: keystone_config.stat.exists - name: Fetch output fetch: src=/tmp/out.yml dest=/tmp/out.yml flat=yes + when: keystone_config.stat.exists - name: Load configuration variables include_vars: /tmp/out.yml + when: keystone_config.stat.exists - name: Determine if Keystone is deployed in eventlet shell: ps afx | grep "[Kk]eystone-all" -c diff --git a/ansible/gather/roles/neutron/tasks/main.yml b/ansible/gather/roles/neutron/tasks/main.yml index 722972019..7113158b8 100644 --- a/ansible/gather/roles/neutron/tasks/main.yml +++ b/ansible/gather/roles/neutron/tasks/main.yml @@ -3,15 +3,23 @@ # Tasks to get neutron facts # +- name: Check that Neutron is installed + become: true + stat: path=/etc/neutron/neutron.conf + register: neutron_config + - name: Parse Neutron config become: true shell: python /tmp/openstack-config-parser.py neutron /etc/neutron/neutron.conf /tmp/out.yml + when: neutron_config.stat.exists - name: Fetch output fetch: src=/tmp/out.yml dest=/tmp/out.yml flat=yes + when: neutron_config.stat.exists - name: Load configuration variables include_vars: /tmp/out.yml + when: neutron_config.stat.exists - name: Parse Neutron plugin.ini become: true diff --git a/ansible/gather/roles/nova/tasks/main.yml b/ansible/gather/roles/nova/tasks/main.yml index 91eac9e8d..1b09f5846 100644 --- a/ansible/gather/roles/nova/tasks/main.yml +++ b/ansible/gather/roles/nova/tasks/main.yml @@ -3,13 +3,21 @@ # Tasks to get nova facts # +- name: Check that Nova is installed + become: true + stat: path=/etc/nova/nova.conf + register: nova_config + - name: Parse Nova config become: true shell: python /tmp/openstack-config-parser.py nova /etc/nova/nova.conf /tmp/out.yml + when: nova_config.stat.exists - name: Fetch output fetch: src=/tmp/out.yml dest=/tmp/out.yml flat=yes + when: nova_config.stat.exists - name: Load configuration variables include_vars: /tmp/out.yml + when: nova_config.stat.exists diff --git a/ansible/install/roles/no-sshd-dns/tasks/main.yml b/ansible/install/roles/no-sshd-dns/tasks/main.yml index 14c7abec9..23227c366 100644 --- a/ansible/install/roles/no-sshd-dns/tasks/main.yml +++ b/ansible/install/roles/no-sshd-dns/tasks/main.yml @@ -3,10 +3,12 @@ - name: Disable DNS resolution in Overcloud sshd config lineinfile: dest=/etc/ssh/sshd_config line="UseDNS no" state=present - become: true when: "{{disable_ssh_dns}}" + become: true + become_user: root - name: Restart sshd service service: name=sshd state=restarted - become: true when: "{{disable_ssh_dns}}" + become: true + become_user: root diff --git a/ansible/oooq/baremetal-virt-undercloud-tripleo-browbeat.yml b/ansible/oooq/baremetal-virt-undercloud-tripleo-browbeat.yml index 024f8c251..2d689108d 100644 --- a/ansible/oooq/baremetal-virt-undercloud-tripleo-browbeat.yml +++ b/ansible/oooq/baremetal-virt-undercloud-tripleo-browbeat.yml @@ -18,6 +18,12 @@ - browbeat/common - browbeat/browbeat - browbeat/browbeat-network + +- name: Disable sshd dns + hosts: overcloud + vars: + disable_ssh_dns: true + roles: - browbeat/no-sshd-dns - name: Run Browbeat