Specify 'become' for only necessary tasks (Queens roles)

Add become to only neccesary tasks in roles:

- blazar
- opendaylight
- redis
- tempest
- vitrage

Change-Id: Ib3a48c1c21a19a23e87d2e465fd7012e3eee7565
Partial-Implements: blueprint ansible-specific-task-become
This commit is contained in:
Duong Ha-Quang 2018-03-13 15:55:31 +07:00
parent ee00e3eeb3
commit 542e1f87d1
5 changed files with 66 additions and 4 deletions

View File

@ -3,7 +3,10 @@
file: file:
path: "{{ node_config_directory }}/{{ item.key }}" path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory" state: "directory"
recurse: yes owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}"
mode: "0770"
become: true
when: when:
- inventory_hostname in groups[item.value.group] - inventory_hostname in groups[item.value.group]
- item.value.enabled | bool - item.value.enabled | bool
@ -30,6 +33,8 @@
template: template:
src: "{{ item.key }}.json.j2" src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json" dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
mode: "0660"
become: true
register: blazar_config_jsons register: blazar_config_jsons
when: when:
- item.value.enabled | bool - item.value.enabled | bool
@ -50,6 +55,8 @@
- "{{ node_custom_config }}/blazar/{{ item.key }}.conf" - "{{ node_custom_config }}/blazar/{{ item.key }}.conf"
- "{{ node_custom_config }}/blazar/{{ inventory_hostname }}/blazar.conf" - "{{ node_custom_config }}/blazar/{{ inventory_hostname }}/blazar.conf"
dest: "{{ node_config_directory }}/{{ item.key }}/blazar.conf" dest: "{{ node_config_directory }}/{{ item.key }}/blazar.conf"
mode: "0660"
become: true
register: blazar_confs register: blazar_confs
when: when:
- item.value.enabled | bool - item.value.enabled | bool
@ -63,6 +70,8 @@
template: template:
src: "{{ blazar_policy_file_path }}" src: "{{ blazar_policy_file_path }}"
dest: "{{ node_config_directory }}/{{ item.key }}/{{ blazar_policy_file }}" dest: "{{ node_config_directory }}/{{ item.key }}/{{ blazar_policy_file }}"
mode: "0660"
become: true
register: blazar_policy_overwriting register: blazar_policy_overwriting
when: when:
- blazar_policy_file is defined - blazar_policy_file is defined

View File

@ -1,5 +1,6 @@
--- ---
- name: Setting sysctl values - name: Setting sysctl values
become: true
sysctl: name={{ item.name }} value={{ item.value }} sysctl_set=yes sysctl: name={{ item.name }} value={{ item.value }} sysctl_set=yes
with_items: with_items:
- { name: "net.bridge.bridge-nf-call-iptables", value: 1} - { name: "net.bridge.bridge-nf-call-iptables", value: 1}
@ -14,7 +15,10 @@
file: file:
path: "{{ node_config_directory }}/{{ item }}" path: "{{ node_config_directory }}/{{ item }}"
state: "directory" state: "directory"
recurse: yes owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}"
mode: "0770"
become: true
with_items: with_items:
- "opendaylight" - "opendaylight"
@ -23,6 +27,8 @@
template: template:
src: "{{ item }}.json.j2" src: "{{ item }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json" dest: "{{ node_config_directory }}/{{ item }}/config.json"
mode: "0660"
become: true
with_items: with_items:
- "opendaylight" - "opendaylight"
notify: notify:
@ -33,6 +39,8 @@
template: template:
src: "{{ role_path }}/templates/custom.properties.j2" src: "{{ role_path }}/templates/custom.properties.j2"
dest: "{{ node_config_directory }}/opendaylight/custom.properties" dest: "{{ node_config_directory }}/opendaylight/custom.properties"
mode: "0660"
become: true
notify: notify:
- Restart opendaylight container - Restart opendaylight container
@ -41,6 +49,8 @@
template: template:
src: "{{ role_path }}/templates/start-odl.j2" src: "{{ role_path }}/templates/start-odl.j2"
dest: "{{ node_config_directory }}/opendaylight/start-odl" dest: "{{ node_config_directory }}/opendaylight/start-odl"
mode: "0660"
become: true
notify: notify:
- Restart opendaylight container - Restart opendaylight container
@ -49,6 +59,8 @@
template: template:
src: "{{ role_path }}/templates/jetty.xml.j2" src: "{{ role_path }}/templates/jetty.xml.j2"
dest: "{{ node_config_directory }}/{{ item }}/jetty.xml" dest: "{{ node_config_directory }}/{{ item }}/jetty.xml"
mode: "0660"
become: true
with_items: with_items:
- "opendaylight" - "opendaylight"
notify: notify:
@ -59,6 +71,8 @@
template: template:
src: "{{ role_path }}/templates/org.apache.karaf.features.cfg.j2" src: "{{ role_path }}/templates/org.apache.karaf.features.cfg.j2"
dest: "{{ node_config_directory }}/{{ item }}/org.apache.karaf.features.cfg" dest: "{{ node_config_directory }}/{{ item }}/org.apache.karaf.features.cfg"
mode: "0660"
become: true
with_items: with_items:
- "opendaylight" - "opendaylight"
notify: notify:
@ -69,6 +83,8 @@
template: template:
src: "{{ role_path }}/templates/org.opendaylight.ovsdb.library.cfg.j2" src: "{{ role_path }}/templates/org.opendaylight.ovsdb.library.cfg.j2"
dest: "{{ node_config_directory }}/{{ item }}/org.opendaylight.ovsdb.library.cfg" dest: "{{ node_config_directory }}/{{ item }}/org.opendaylight.ovsdb.library.cfg"
mode: "0660"
become: true
with_items: with_items:
- "opendaylight" - "opendaylight"
notify: notify:
@ -78,6 +94,8 @@
template: template:
src: "{{ role_path }}/templates/tomcat-server.xml.j2" src: "{{ role_path }}/templates/tomcat-server.xml.j2"
dest: "{{ node_config_directory }}/{{ item }}/tomcat-server.xml" dest: "{{ node_config_directory }}/{{ item }}/tomcat-server.xml"
mode: "0660"
become: true
register: opendaylight_config_tomcat register: opendaylight_config_tomcat
with_items: with_items:
- "opendaylight" - "opendaylight"
@ -88,6 +106,8 @@
template: template:
src: "{{ role_path }}/templates/org.ops4j.pax.logging.cfg.j2" src: "{{ role_path }}/templates/org.ops4j.pax.logging.cfg.j2"
dest: "{{ node_config_directory }}/{{ item }}/org.ops4j.pax.logging.cfg" dest: "{{ node_config_directory }}/{{ item }}/org.ops4j.pax.logging.cfg"
mode: "0660"
become: true
register: opendaylight_config_logging register: opendaylight_config_logging
with_items: with_items:
- "opendaylight" - "opendaylight"
@ -98,6 +118,8 @@
template: template:
src: "{{ role_path }}/templates/netvirt-impl-config_netvirt-impl-config.xml.j2" src: "{{ role_path }}/templates/netvirt-impl-config_netvirt-impl-config.xml.j2"
dest: "{{ node_config_directory }}/{{ item }}/netvirt-impl-config_netvirt-impl-config.xml" dest: "{{ node_config_directory }}/{{ item }}/netvirt-impl-config_netvirt-impl-config.xml"
mode: "0660"
become: true
register: opendaylight_config_netvirt register: opendaylight_config_netvirt
with_items: with_items:
- "opendaylight" - "opendaylight"
@ -108,6 +130,8 @@
template: template:
src: "{{ role_path }}/templates/netvirt-aclservice-config.xml.j2" src: "{{ role_path }}/templates/netvirt-aclservice-config.xml.j2"
dest: "{{ node_config_directory }}/{{ item }}/netvirt-aclservice-config.xml" dest: "{{ node_config_directory }}/{{ item }}/netvirt-aclservice-config.xml"
mode: "0660"
become: true
register: opendaylight_config_netvirt_acl register: opendaylight_config_netvirt_acl
with_items: with_items:
- "opendaylight" - "opendaylight"
@ -118,6 +142,8 @@
template: template:
src: "{{ role_path }}/templates/setenv.j2" src: "{{ role_path }}/templates/setenv.j2"
dest: "{{ node_config_directory }}/{{ item }}/setenv" dest: "{{ node_config_directory }}/{{ item }}/setenv"
mode: "0660"
become: true
register: opendaylight_config_env register: opendaylight_config_env
with_items: with_items:
- "opendaylight" - "opendaylight"
@ -128,6 +154,8 @@
template: template:
src: "{{ item }}" src: "{{ item }}"
dest: "{{ node_config_directory }}/opendaylight/akka.conf" dest: "{{ node_config_directory }}/opendaylight/akka.conf"
mode: "0660"
become: true
with_first_found: with_first_found:
- "{{ node_custom_config }}/opendaylight/{{ inventory_hostname }}/akka.conf" - "{{ node_custom_config }}/opendaylight/{{ inventory_hostname }}/akka.conf"
- "{{ node_custom_config }}/opendaylight/akka.conf" - "{{ node_custom_config }}/opendaylight/akka.conf"
@ -140,6 +168,8 @@
template: template:
src: "{{ item }}" src: "{{ item }}"
dest: "{{ node_config_directory }}/opendaylight/modules.conf" dest: "{{ node_config_directory }}/opendaylight/modules.conf"
mode: "0660"
become: true
with_first_found: with_first_found:
- "{{ node_custom_config }}/opendaylight/{{ inventory_hostname }}/modules.conf" - "{{ node_custom_config }}/opendaylight/{{ inventory_hostname }}/modules.conf"
- "{{ node_custom_config }}/opendaylight/modules.conf" - "{{ node_custom_config }}/opendaylight/modules.conf"
@ -152,6 +182,8 @@
template: template:
src: "{{ item }}" src: "{{ item }}"
dest: "{{ node_config_directory }}/opendaylight/module-shards.conf" dest: "{{ node_config_directory }}/opendaylight/module-shards.conf"
mode: "0660"
become: true
with_first_found: with_first_found:
- "{{ node_custom_config }}/opendaylight/{{ inventory_hostname }}/module-shards.conf" - "{{ node_custom_config }}/opendaylight/{{ inventory_hostname }}/module-shards.conf"
- "{{ node_custom_config }}/opendaylight/module-shards.conf" - "{{ node_custom_config }}/opendaylight/module-shards.conf"

View File

@ -3,7 +3,10 @@
file: file:
path: "{{ node_config_directory }}/{{ item.key }}" path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory" state: "directory"
recurse: yes owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}"
mode: "0770"
become: true
when: when:
- inventory_hostname in groups[item.value.group] - inventory_hostname in groups[item.value.group]
- item.value.enabled | bool - item.value.enabled | bool
@ -13,6 +16,8 @@
template: template:
src: "{{ item.key }}.json.j2" src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json" dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
mode: "0660"
become: true
register: redis_config_jsons register: redis_config_jsons
when: when:
- inventory_hostname in groups[item.value.group] - inventory_hostname in groups[item.value.group]
@ -25,6 +30,8 @@
template: template:
src: "{{ item.key }}.conf.j2" src: "{{ item.key }}.conf.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/redis.conf" dest: "{{ node_config_directory }}/{{ item.key }}/redis.conf"
mode: "0660"
become: true
register: redis_confs register: redis_confs
when: when:
- inventory_hostname in groups[item.value.group] - inventory_hostname in groups[item.value.group]

View File

@ -6,6 +6,7 @@
owner: "{{ config_owner_user }}" owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}" group: "{{ config_owner_group }}"
mode: "0770" mode: "0770"
become: true
when: when:
- inventory_hostname in groups[item.value.group] - inventory_hostname in groups[item.value.group]
- item.value.enabled | bool - item.value.enabled | bool
@ -16,6 +17,7 @@
src: "{{ item.key }}.json.j2" src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json" dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
mode: "0660" mode: "0660"
become: true
register: tempest_config_jsons register: tempest_config_jsons
when: when:
- inventory_hostname in groups[item.value.group] - inventory_hostname in groups[item.value.group]
@ -33,6 +35,7 @@
- "{{ node_custom_config }}/tempest.conf" - "{{ node_custom_config }}/tempest.conf"
dest: "{{ node_config_directory }}/{{ item.key }}/tempest.conf" dest: "{{ node_config_directory }}/{{ item.key }}/tempest.conf"
mode: "0660" mode: "0660"
become: true
register: tempest_confs register: tempest_confs
when: when:
- inventory_hostname in groups[item.value.group] - inventory_hostname in groups[item.value.group]

View File

@ -3,7 +3,10 @@
file: file:
path: "{{ node_config_directory }}/{{ item.key }}" path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory" state: "directory"
recurse: yes owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}"
mode: "0770"
become: true
when: when:
- inventory_hostname in groups[item.value.group] - inventory_hostname in groups[item.value.group]
- item.value.enabled | bool - item.value.enabled | bool
@ -30,6 +33,8 @@
template: template:
src: "{{ item.key }}.json.j2" src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json" dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
mode: "0770"
become: true
register: vitrage_config_jsons register: vitrage_config_jsons
when: when:
- inventory_hostname in groups[item.value.group] - inventory_hostname in groups[item.value.group]
@ -54,6 +59,8 @@
- "{{ node_config_directory }}/config/vitrage/{{ item.key }}.conf" - "{{ node_config_directory }}/config/vitrage/{{ item.key }}.conf"
- "{{ node_config_directory }}/config/vitrage/{{ inventory_hostname }}/vitrage.conf" - "{{ node_config_directory }}/config/vitrage/{{ inventory_hostname }}/vitrage.conf"
dest: "{{ node_config_directory }}/{{ item.key }}/vitrage.conf" dest: "{{ node_config_directory }}/{{ item.key }}/vitrage.conf"
mode: "0770"
become: true
register: vitrage_confs register: vitrage_confs
when: when:
- inventory_hostname in groups[item.value.group] - inventory_hostname in groups[item.value.group]
@ -70,6 +77,8 @@
template: template:
src: "wsgi-vitrage.conf.j2" src: "wsgi-vitrage.conf.j2"
dest: "{{ node_config_directory }}/{{ item }}/wsgi-vitrage.conf" dest: "{{ node_config_directory }}/{{ item }}/wsgi-vitrage.conf"
mode: "0770"
become: true
with_items: with_items:
- "vitrage-api" - "vitrage-api"
notify: notify:
@ -79,6 +88,8 @@
template: template:
src: "{{ vitrage_policy_file_path }}" src: "{{ vitrage_policy_file_path }}"
dest: "{{ node_config_directory }}/{{ item.key }}/{{ vitrage_policy_file }}" dest: "{{ node_config_directory }}/{{ item.key }}/{{ vitrage_policy_file }}"
mode: "0770"
become: true
register: vitrage_policy_overwriting register: vitrage_policy_overwriting
when: when:
- vitrage_policy_file is defined - vitrage_policy_file is defined