From 260411dc66389d0ae9c84c3d8b57e42ad3e0981c Mon Sep 17 00:00:00 2001 From: Masco Kaliyamoorthy Date: Fri, 30 Jul 2021 18:28:16 +0530 Subject: [PATCH] add support for stoping the collectd Change-Id: I0aaa73427101cc53481f12d442dce1f3f312a30a --- ansible/install/stop-collectd-baremetal.yml | 80 +++++++++++++ ansible/install/stop-collectd-container.yml | 122 ++++++++++++++++++++ ansible/install/stop-collectd.yml | 11 ++ 3 files changed, 213 insertions(+) create mode 100644 ansible/install/stop-collectd-baremetal.yml create mode 100644 ansible/install/stop-collectd-container.yml create mode 100644 ansible/install/stop-collectd.yml diff --git a/ansible/install/stop-collectd-baremetal.yml b/ansible/install/stop-collectd-baremetal.yml new file mode 100644 index 000000000..5cbe1b359 --- /dev/null +++ b/ansible/install/stop-collectd-baremetal.yml @@ -0,0 +1,80 @@ +--- +# +# Playbook to stop collectd on undercloud/overcloud +# +# Stop on all undercloud/overcloud machines: +# ansible-playbook -i hosts.yml install/stop-collectd-baremetal.yml +# +# Or use tags: +# ansible-playbook -i hosts.yml install/stop-collectd-baremetal.yml --tag "undercloud" +# ansible-playbook -i hosts.yml install/stop-collectd-baremetal.yml --tag "controller" +# ansible-playbook -i hosts.yml install/stop-collectd-baremetal.yml --tag "networker" +# ansible-playbook -i hosts.yml install/stop-collectd-baremetal.yml --tag "blockstorage" +# ansible-playbook -i hosts.yml install/stop-collectd-baremetal.yml --tag "objectstorage" +# ansible-playbook -i hosts.yml install/stop-collectd-baremetal.yml --tag "cephstorage" +# ansible-playbook -i hosts.yml install/stop-collectd-baremetal.yml --tag "compute" +# + + +- hosts: Undercloud + remote_user: "{{ local_remote_user }}" + tasks: + - name: Stop Collectd on undercloud + service: name=collectd state=stopped enabled=false + become: true + ignore_errors: true + tags: undercloud + +- hosts: Controller + remote_user: "{{ host_remote_user }}" + tasks: + - name: Stop Collectd on controller + service: name=collectd state=stopped enabled=false + become: true + ignore_errors: true + tags: controller + +- hosts: Networker + remote_user: "{{ host_remote_user }}" + tasks: + - name: Stop Collectd on networker + service: name=collectd state=stopped enabled=false + become: true + ignore_errors: true + tags: networker + +- hosts: BlockStorage + remote_user: "{{ host_remote_user }}" + tasks: + - name: Stop Collectd on blockstorage + service: name=collectd state=stopped enabled=false + become: true + ignore_errors: true + tags: blockstorage + +- hosts: ObjectStorage + remote_user: "{{ host_remote_user }}" + tasks: + - name: Stop Collectd on objectstorage + service: name=collectd state=stopped enabled=false + become: true + ignore_errors: true + tags: objectstorage + +- hosts: CephStorage + remote_user: "{{ host_remote_user }}" + tasks: + - name: Stop Collectd on cephstorage + service: name=collectd state=stopped enabled=false + become: true + ignore_errors: true + tags: cephstorage + +- hosts: Compute + remote_user: "{{ host_remote_user }}" + tasks: + - name: Stop Collectd on compute + service: name=collectd state=stopped enabled=false + become: true + ignore_errors: true + tags: compute diff --git a/ansible/install/stop-collectd-container.yml b/ansible/install/stop-collectd-container.yml new file mode 100644 index 000000000..313361037 --- /dev/null +++ b/ansible/install/stop-collectd-container.yml @@ -0,0 +1,122 @@ + +# +# Playbook to stop collectd on undercloud/overcloud +# +# Stop collectd on all undercloud/overcloud machines: +# ansible-playbook -i hosts.yaml install/stop-collectd-container.yml +# +# Or use tags: +# ansible-playbook -i hosts.yml install/stop-collectd-container.yml --tag "undercloud" +# ansible-playbook -i hosts.yml install/stop-collectd-container.yml --tag "controller" +# ansible-playbook -i hosts.yml install/stop-collectd-container.yml --tag "networker" +# ansible-playbook -i hosts.yml install/stop-collectd-container.yml --tag "blockstorage" +# ansible-playbook -i hosts.yml install/stop-collectd-container.yml --tag "objectstorage" +# ansible-playbook -i hosts.yml install/stop-collectd-container.yml --tag "cephstorage" +# ansible-playbook -i hosts.yml install/stop-collectd-container.yml --tag "compute" +# + + +- hosts: Undercloud + remote_user: "{{ local_remote_user }}" + vars: + config_type: undercloud + roles: + - { role: osp_version } + - { role: containers } + tasks: + - name: Stop Collectd on {{ config_type }} + shell: | + {{ container_cli }} stop collectd-{{ config_type }} + become: yes + ignore_errors: true + tags: undercloud + +- hosts: Controller + remote_user: "{{ host_remote_user }}" + vars: + config_type: controller + roles: + - { role: osp_version } + - { role: containers } + tasks: + - name: Stop Collectd on {{ config_type }} + shell: | + {{ container_cli }} stop collectd-{{ config_type }} + become: yes + ignore_errors: true + tags: controller + +- hosts: Networker + remote_user: "{{ host_remote_user }}" + vars: + config_type: networker + roles: + - { role: osp_version } + - { role: containers } + tasks: + - name: Stop Collectd on {{ config_type }} + shell: | + {{ container_cli }} stop collectd-{{ config_type }} + become: yes + ignore_errors: true + tags: networker + +- hosts: BlockStorage + remote_user: "{{ host_remote_user }}" + vars: + config_type: blockstorage + roles: + - { role: osp_version } + - { role: containers } + tasks: + - name: Stop Collectd on {{ config_type }} + shell: | + {{ container_cli }} stop collectd-{{ config_type }} + become: yes + ignore_errors: true + tags: blockstorage + +- hosts: ObjectStorage + remote_user: "{{ host_remote_user }}" + vars: + config_type: objectstorage + roles: + - { role: osp_version } + - { role: containers } + tasks: + - name: Stop Collectd on {{ config_type }} + shell: | + {{ container_cli }} stop collectd-{{ config_type }} + become: yes + ignore_errors: true + tags: objectstorage + +- hosts: CephStorage + remote_user: "{{ host_remote_user }}" + vars: + config_type: cephstorage + roles: + - { role: osp_version } + - { role: containers } + tasks: + - name: Stop Collectd on {{ config_type }} + shell: | + {{ container_cli }} stop collectd-{{ config_type }} + become: yes + ignore_errors: true + tags: cephstorage + +- hosts: Compute + remote_user: "{{ host_remote_user }}" + vars: + config_type: compute + roles: + - { role: osp_version } + - { role: containers } + tasks: + - name: Stop Collectd on {{ config_type }} + shell: | + {{ container_cli }} stop collectd-{{ config_type }} + become: yes + ignore_errors: true + tags: compute diff --git a/ansible/install/stop-collectd.yml b/ansible/install/stop-collectd.yml new file mode 100644 index 000000000..dff8c48cc --- /dev/null +++ b/ansible/install/stop-collectd.yml @@ -0,0 +1,11 @@ +--- +- name: set fact collectd_container + import_playbook: pre-collectd.yml + +- name: Run containerized collectd (Stein and greater recommended) + import_playbook: stop-collectd-container.yml + when: hostvars['undercloud']['collectd_container'] + +- name: Run collectd installed through RPMs + import_playbook: stop-collectd-baremetal.yml + when: not hostvars['undercloud']['collectd_container']