Removed Ansible become from Conmon install

This commit changes the conmon install playbook as well as the
required tasks and handlers to use become instead of having
the whole playbook run as root by ansible_become. The playbook
has been tested against my own cloud.

https://trello.com/c/KBFbahdV/38-ansible-remove-ansible-become-from-vars-and-use-become-instead

Change-Id: Icf89451371dd9fc5da9880d6a00ae91c88011970
This commit is contained in:
jkilpatr 2016-07-20 09:40:43 -04:00
parent cd09901a99
commit cd3a910ac0
12 changed files with 39 additions and 9 deletions

View File

@ -6,7 +6,6 @@
- hosts: undercloud - hosts: undercloud
remote_user: "{{ local_remote_user }}" remote_user: "{{ local_remote_user }}"
vars: vars:
ansible_become: true
undercloud: true undercloud: true
roles: roles:
- common - common
@ -15,7 +14,6 @@
- hosts: controller - hosts: controller
remote_user: "{{ host_remote_user }}" remote_user: "{{ host_remote_user }}"
vars: vars:
ansible_become: true
undercloud: false undercloud: false
roles: roles:
- common - common

View File

@ -5,6 +5,7 @@
- name: unmanage cinder services - name: unmanage cinder services
command: pcs resource unmanage {{ item }} command: pcs resource unmanage {{ item }}
become: true
with_items: with_items:
- openstack-cinder-api - openstack-cinder-api
- openstack-cinder-scheduler - openstack-cinder-scheduler
@ -13,6 +14,7 @@
- name: restart cinder services - name: restart cinder services
service: name={{ item }} state=restarted service: name={{ item }} state=restarted
become: true
with_items: with_items:
- openstack-cinder-api - openstack-cinder-api
- openstack-cinder-scheduler - openstack-cinder-scheduler
@ -20,6 +22,7 @@
- name: manage cinder services - name: manage cinder services
command: pcs resource manage {{ item }} command: pcs resource manage {{ item }}
become: true
with_items: with_items:
- openstack-cinder-api - openstack-cinder-api
- openstack-cinder-scheduler - openstack-cinder-scheduler
@ -28,6 +31,7 @@
- name: cleanup cinder services - name: cleanup cinder services
command: pcs resource cleanup {{ item }} command: pcs resource cleanup {{ item }}
become: true
with_items: with_items:
- openstack-cinder-api - openstack-cinder-api
- openstack-cinder-scheduler - openstack-cinder-scheduler

View File

@ -6,12 +6,14 @@
- name: Check for connmon in cinder.conf - name: Check for connmon in cinder.conf
shell: grep -Eq 'connection\s?=\s?mysql:' /etc/cinder/cinder.conf shell: grep -Eq 'connection\s?=\s?mysql:' /etc/cinder/cinder.conf
register: cinder_mysql register: cinder_mysql
become: true
ignore_errors: true ignore_errors: true
changed_when: false changed_when: false
- name: Enable Connmon in cinder.conf - name: Enable Connmon in cinder.conf
shell: sed -i 's/mysql:/mysql+connmon:/g' /etc/cinder/cinder.conf shell: sed -i 's/mysql:/mysql+connmon:/g' /etc/cinder/cinder.conf
when: cinder_mysql.rc == 0 when: cinder_mysql.rc == 0
become: true
notify: notify:
- unmanage cinder services - unmanage cinder services
- restart cinder services - restart cinder services

View File

@ -5,9 +5,11 @@
- name: Install pip - name: Install pip
easy_install: name=pip easy_install: name=pip
become: true
- name: Install connmon - name: Install connmon
pip: name=connmon pip: name=connmon
become: true
# #
# Connmon Setup # Connmon Setup
@ -20,9 +22,11 @@
owner: root owner: root
group: root group: root
mode: 0644 mode: 0644
become: true
- name: Install Screen for connmon - name: Install Screen for connmon
yum: name=screen state=latest yum: name=screen state=latest
become: true
when: undercloud when: undercloud
# To remove the screen session: screen -X -S connmond kill # To remove the screen session: screen -X -S connmond kill
@ -31,12 +35,6 @@
when: undercloud when: undercloud
changed_when: false changed_when: false
- name: Change connmon result owner
command: chown "{{ local_remote_user }}":"{{ local_remote_user }}" /tmp/connmon_results.csv
when: undercloud
changed_when: false
ignore_errors: true
### begin firewall ### ### begin firewall ###
# we need TCP/5555 open # we need TCP/5555 open
# determine firewall status and take action # determine firewall status and take action
@ -76,8 +74,9 @@
- name: (connmon) check firewall rules for TCP/{{connmon_port}} (iptables-services) - name: (connmon) check firewall rules for TCP/{{connmon_port}} (iptables-services)
shell: grep "dport {{connmon_port}} \-j ACCEPT" /etc/sysconfig/iptables | wc -l shell: grep "dport {{connmon_port}} \-j ACCEPT" /etc/sysconfig/iptables | wc -l
ignore_errors: true ignore_errors: true
become: true
register: iptables_tcp5800_exists register: iptables_tcp5800_exists
failed_when: iptables_tcp{{connmon_port}}_exists == 127 failed_when: iptables_tcp{{connmon_port}}_exists == 127i
no_log: true no_log: true
- name: (connmon) Add firewall rule for TCP/{{connmon_port}} (iptables-services) - name: (connmon) Add firewall rule for TCP/{{connmon_port}} (iptables-services)
@ -87,12 +86,14 @@
regexp: '^INPUT -i lo -j ACCEPT' regexp: '^INPUT -i lo -j ACCEPT'
insertbefore: '-A INPUT -i lo -j ACCEPT' insertbefore: '-A INPUT -i lo -j ACCEPT'
backup: yes backup: yes
become: true
when: firewalld_in_use.rc != 0 and firewalld_is_active.rc != 0 and iptables_tcp5800_exists.stdout|int == 0 when: firewalld_in_use.rc != 0 and firewalld_is_active.rc != 0 and iptables_tcp5800_exists.stdout|int == 0
register: iptables_needs_restart register: iptables_needs_restart
- name: (connmon) Restart iptables-services for TCP/{{connmon_port}} (iptables-services) - name: (connmon) Restart iptables-services for TCP/{{connmon_port}} (iptables-services)
shell: systemctl restart iptables.service shell: systemctl restart iptables.service
ignore_errors: true ignore_errors: true
become: true
when: iptables_needs_restart != 0 and firewalld_in_use.rc != 0 and firewalld_is_active.rc != 0 when: iptables_needs_restart != 0 and firewalld_in_use.rc != 0 and firewalld_is_active.rc != 0
### end firewall ### ### end firewall ###

View File

@ -5,6 +5,7 @@
# #
- name: unmanage heat services - name: unmanage heat services
command: pcs resource unmanage {{ item }} command: pcs resource unmanage {{ item }}
become: true
with_items: with_items:
- openstack-heat-api - openstack-heat-api
- openstack-heat-engine - openstack-heat-engine
@ -12,12 +13,14 @@
- name: restart heat services - name: restart heat services
service: name={{ item }} state=restarted service: name={{ item }} state=restarted
become: true
with_items: with_items:
- openstack-heat-api - openstack-heat-api
- openstack-heat-engine - openstack-heat-engine
- name: manage heat services - name: manage heat services
command: pcs resource manage {{ item }} command: pcs resource manage {{ item }}
become: true
with_items: with_items:
- openstack-heat-api - openstack-heat-api
- openstack-heat-engine - openstack-heat-engine
@ -25,6 +28,7 @@
- name: cleanup heat services - name: cleanup heat services
command: pcs resource cleanup {{ item }} command: pcs resource cleanup {{ item }}
become: true
with_items: with_items:
- openstack-heat-api - openstack-heat-api
- openstack-heat-engine - openstack-heat-engine

View File

@ -5,12 +5,14 @@
- name: Check for connmon in heat.conf - name: Check for connmon in heat.conf
shell: grep -Eq 'connection\s?=\s?mysql:' /etc/heat/heat.conf shell: grep -Eq 'connection\s?=\s?mysql:' /etc/heat/heat.conf
register: heat_mysql register: heat_mysql
become: true
ignore_errors: true ignore_errors: true
changed_when: false changed_when: false
- name: Enable Connmon in heat.conf - name: Enable Connmon in heat.conf
shell: sed -i 's/mysql:/mysql+connmon:/g' /etc/heat/heat.conf shell: sed -i 's/mysql:/mysql+connmon:/g' /etc/heat/heat.conf
when: heat_mysql.rc == 0 when: heat_mysql.rc == 0
become: true
notify: notify:
- unmanage heat services - unmanage heat services
- restart heat services - restart heat services

View File

@ -10,6 +10,7 @@
- name: restart httpd - name: restart httpd
service: name=httpd state=restarted service: name=httpd state=restarted
when: "'httpd' == '{{ keystone_deployment }}'" when: "'httpd' == '{{ keystone_deployment }}'"
become: true
# #
# Restart keystone when in eventlet # Restart keystone when in eventlet
@ -18,18 +19,22 @@
- name: unmanage keystone - name: unmanage keystone
command: pcs resource unmanage openstack-keystone command: pcs resource unmanage openstack-keystone
when: "'eventlet' == '{{ keystone_deployment }}'" when: "'eventlet' == '{{ keystone_deployment }}'"
become: true
ignore_errors: true ignore_errors: true
- name: restart keystone - name: restart keystone
service: name=openstack-keystone state=restarted service: name=openstack-keystone state=restarted
when: "'eventlet' == '{{ keystone_deployment }}'" when: "'eventlet' == '{{ keystone_deployment }}'"
become: true
- name: manage keystone - name: manage keystone
command: pcs resource manage openstack-keystone command: pcs resource manage openstack-keystone
when: "'eventlet' == '{{ keystone_deployment }}'" when: "'eventlet' == '{{ keystone_deployment }}'"
become: true
ignore_errors: true ignore_errors: true
- name: cleanup keystone - name: cleanup keystone
command: pcs resource cleanup openstack-keystone command: pcs resource cleanup openstack-keystone
when: "'eventlet' == '{{ keystone_deployment }}'" when: "'eventlet' == '{{ keystone_deployment }}'"
become: true
ignore_errors: true ignore_errors: true

View File

@ -24,12 +24,14 @@
- name: Check for connmon in keystone.conf - name: Check for connmon in keystone.conf
shell: grep -Eq 'connection\s?=\s?mysql:' /etc/keystone/keystone.conf shell: grep -Eq 'connection\s?=\s?mysql:' /etc/keystone/keystone.conf
register: keystone_mysql register: keystone_mysql
become: true
ignore_errors: true ignore_errors: true
changed_when: false changed_when: false
- name: Enable connmon in keystone.conf - name: Enable connmon in keystone.conf
shell: sed -i 's/mysql:/mysql+connmon:/g' /etc/keystone/keystone.conf shell: sed -i 's/mysql:/mysql+connmon:/g' /etc/keystone/keystone.conf
when: keystone_mysql.rc == 0 when: keystone_mysql.rc == 0
become: true
notify: notify:
- restart httpd - restart httpd
- unmanage keystone - unmanage keystone

View File

@ -5,15 +5,19 @@
- name: unmanage neutron-server - name: unmanage neutron-server
command: pcs resource unmanage neutron-server command: pcs resource unmanage neutron-server
become: true
ignore_errors: true ignore_errors: true
- name: restart neutron-server - name: restart neutron-server
service: name=neutron-server state=restarted service: name=neutron-server state=restarted
become: true
- name: manage neutron-server - name: manage neutron-server
command: pcs resource manage neutron-server command: pcs resource manage neutron-server
become: true
ignore_errors: true ignore_errors: true
- name: cleanup neutron-server - name: cleanup neutron-server
command: pcs resource cleanup neutron-server command: pcs resource cleanup neutron-server
become: true
ignore_errors: true ignore_errors: true

View File

@ -6,12 +6,14 @@
- name: Check for connmon in neutron.conf - name: Check for connmon in neutron.conf
shell: grep -Eq 'connection\s?=\s?mysql:' /etc/neutron/neutron.conf shell: grep -Eq 'connection\s?=\s?mysql:' /etc/neutron/neutron.conf
register: neutron_mysql register: neutron_mysql
become: true
ignore_errors: true ignore_errors: true
changed_when: false changed_when: false
- name: Enable Connmon in neutron.conf - name: Enable Connmon in neutron.conf
shell: sed -i 's/mysql:/mysql+connmon:/g' /etc/neutron/neutron.conf shell: sed -i 's/mysql:/mysql+connmon:/g' /etc/neutron/neutron.conf
when: neutron_mysql.rc == 0 when: neutron_mysql.rc == 0
become: true
notify: notify:
- unmanage neutron-server - unmanage neutron-server
- restart neutron-server - restart neutron-server

View File

@ -5,6 +5,7 @@
- name: unmanage nova services - name: unmanage nova services
command: pcs resource unmanage {{ item }} command: pcs resource unmanage {{ item }}
become: true
with_items: with_items:
- openstack-nova-api - openstack-nova-api
- openstack-nova-scheduler - openstack-nova-scheduler
@ -13,6 +14,7 @@
- name: restart nova services - name: restart nova services
service: name={{ item }} state=restarted service: name={{ item }} state=restarted
become: true
with_items: with_items:
- openstack-nova-api - openstack-nova-api
- openstack-nova-scheduler - openstack-nova-scheduler
@ -20,6 +22,7 @@
- name: manage nova services - name: manage nova services
command: pcs resource manage {{ item }} command: pcs resource manage {{ item }}
become: true
with_items: with_items:
- openstack-nova-api - openstack-nova-api
- openstack-nova-scheduler - openstack-nova-scheduler
@ -28,6 +31,7 @@
- name: cleanup nova services - name: cleanup nova services
command: pcs resource cleanup {{ item }} command: pcs resource cleanup {{ item }}
become: true
with_items: with_items:
- openstack-nova-api - openstack-nova-api
- openstack-nova-scheduler - openstack-nova-scheduler

View File

@ -6,12 +6,14 @@
- name: Check for connmon in nova.conf - name: Check for connmon in nova.conf
shell: grep -Eq 'connection\s?=\s?mysql:' /etc/nova/nova.conf shell: grep -Eq 'connection\s?=\s?mysql:' /etc/nova/nova.conf
register: nova_mysql register: nova_mysql
become: true
ignore_errors: true ignore_errors: true
changed_when: false changed_when: false
- name: Enable Connmon in nova.conf - name: Enable Connmon in nova.conf
shell: sed -i 's/mysql:/mysql+connmon:/g' /etc/nova/nova.conf shell: sed -i 's/mysql:/mysql+connmon:/g' /etc/nova/nova.conf
when: nova_mysql.rc == 0 when: nova_mysql.rc == 0
become: true
notify: notify:
- unmanage nova services - unmanage nova services
- restart nova services - restart nova services