From 4038c8226b764cee7afdfe233c68f0d8b9529454 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 12 Apr 2018 15:25:20 +0100 Subject: [PATCH] Change reserved keyword 'action' to 'kayobe_action' For several roles (cadvisor, inspection-store, docker-registry, etc.), we use an 'action' variable, in a similar manner to kolla-ansible, to determine the current action being performed (deploy, reconfigure, upgrade). It is likely this information will be useful for custom playbooks, so we should expose it. The 'action' keyword is reserved, and its use triggers a warning, so we change its name to kayobe_action before advertising it to users. Change-Id: I5ffbb8b014a31e27141bfc8bf780297d81c840be Story: 2001663 Task: 12604 --- ansible/cadvisor.yml | 1 + ansible/docker-registry.yml | 1 + ansible/inspection-store.yml | 1 + ansible/node-exporter.yml | 1 + ansible/opensm.yml | 1 + ansible/roles/cadvisor/defaults/main.yml | 4 ++++ ansible/roles/cadvisor/tasks/main.yml | 2 +- ansible/roles/cadvisor/tasks/pull.yml | 2 +- ansible/roles/docker-registry/defaults/main.yml | 4 ++++ ansible/roles/docker-registry/tasks/main.yml | 2 +- ansible/roles/docker-registry/tasks/pull.yml | 2 +- ansible/roles/inspection-store/defaults/main.yml | 4 ++++ ansible/roles/inspection-store/tasks/main.yml | 2 +- ansible/roles/inspection-store/tasks/pull.yml | 2 +- ansible/roles/node-exporter/defaults/main.yml | 4 ++++ ansible/roles/node-exporter/tasks/main.yml | 2 +- ansible/roles/node-exporter/tasks/pull.yml | 2 +- ansible/roles/opensm/defaults/main.yml | 4 ++++ ansible/roles/opensm/tasks/main.yml | 2 +- ansible/roles/opensm/tasks/pull.yml | 2 +- kayobe/cli/commands.py | 10 +++++----- 21 files changed, 40 insertions(+), 15 deletions(-) diff --git a/ansible/cadvisor.yml b/ansible/cadvisor.yml index 97a51d211..e73cc204f 100644 --- a/ansible/cadvisor.yml +++ b/ansible/cadvisor.yml @@ -12,3 +12,4 @@ - cadvisor roles: - role: cadvisor + cadvisor_action: "{{ kayobe_action }}" diff --git a/ansible/docker-registry.yml b/ansible/docker-registry.yml index 02d5b5553..adf9deba6 100644 --- a/ansible/docker-registry.yml +++ b/ansible/docker-registry.yml @@ -12,3 +12,4 @@ - docker-registry roles: - role: docker-registry + docker_registry_action: "{{ kayobe_action }}" diff --git a/ansible/inspection-store.yml b/ansible/inspection-store.yml index 6317997f5..a4f8e7bad 100644 --- a/ansible/inspection-store.yml +++ b/ansible/inspection-store.yml @@ -12,6 +12,7 @@ - inspection-store roles: - role: inspection-store + inspection_store_action: "{{ kayobe_action }}" inspection_store_enabled: "{{ inspector_store_enabled }}" inspection_store_port: "{{ inspector_store_port }}" inspection_store_config_path: "{{ config_path }}/inspection-store" diff --git a/ansible/node-exporter.yml b/ansible/node-exporter.yml index bdf518c05..405d4ed57 100644 --- a/ansible/node-exporter.yml +++ b/ansible/node-exporter.yml @@ -12,3 +12,4 @@ - node-exporter roles: - role: node-exporter + nodeexporter_action: "{{ kayobe_action }}" diff --git a/ansible/opensm.yml b/ansible/opensm.yml index 55f161fb7..160fa77b0 100644 --- a/ansible/opensm.yml +++ b/ansible/opensm.yml @@ -12,3 +12,4 @@ - opensm roles: - role: opensm + opensm_action: "{{ kayobe_action }}" diff --git a/ansible/roles/cadvisor/defaults/main.yml b/ansible/roles/cadvisor/defaults/main.yml index ef15af4c2..04dba8cad 100644 --- a/ansible/roles/cadvisor/defaults/main.yml +++ b/ansible/roles/cadvisor/defaults/main.yml @@ -1,6 +1,10 @@ --- # Roughly follows kolla-ansible's service deployment patterns. +# Action to perform. One of 'deploy', 'destroy', 'pull', 'reconfigure', +# 'upgrade'. +cadvisor_action: deploy + # Whether cAdvisor is enabled. cadvisor_enabled: false diff --git a/ansible/roles/cadvisor/tasks/main.yml b/ansible/roles/cadvisor/tasks/main.yml index b017e8b4a..8c58a92d9 100644 --- a/ansible/roles/cadvisor/tasks/main.yml +++ b/ansible/roles/cadvisor/tasks/main.yml @@ -1,2 +1,2 @@ --- -- include: "{{ action }}.yml" +- include: "{{ cadvisor_action }}.yml" diff --git a/ansible/roles/cadvisor/tasks/pull.yml b/ansible/roles/cadvisor/tasks/pull.yml index 5800ef342..3e3098c17 100644 --- a/ansible/roles/cadvisor/tasks/pull.yml +++ b/ansible/roles/cadvisor/tasks/pull.yml @@ -7,4 +7,4 @@ with_dict: "{{ cadvisor_services }}" when: - item.value.enabled - - action != 'destroy' + - cadvisor_action != 'destroy' diff --git a/ansible/roles/docker-registry/defaults/main.yml b/ansible/roles/docker-registry/defaults/main.yml index 673a638d3..0b5097362 100644 --- a/ansible/roles/docker-registry/defaults/main.yml +++ b/ansible/roles/docker-registry/defaults/main.yml @@ -1,6 +1,10 @@ --- # Roughly follows kolla-ansible's service deployment patterns. +# Action to perform. One of 'deploy', 'destroy', 'pull', 'reconfigure', +# 'upgrade'. +docker_registry_action: deploy + # Whether a docker registry is enabled. docker_registry_enabled: true diff --git a/ansible/roles/docker-registry/tasks/main.yml b/ansible/roles/docker-registry/tasks/main.yml index b017e8b4a..8b3c80e88 100644 --- a/ansible/roles/docker-registry/tasks/main.yml +++ b/ansible/roles/docker-registry/tasks/main.yml @@ -1,2 +1,2 @@ --- -- include: "{{ action }}.yml" +- include: "{{ docker_registry_action }}.yml" diff --git a/ansible/roles/docker-registry/tasks/pull.yml b/ansible/roles/docker-registry/tasks/pull.yml index afb8dbe45..35d46a961 100644 --- a/ansible/roles/docker-registry/tasks/pull.yml +++ b/ansible/roles/docker-registry/tasks/pull.yml @@ -7,4 +7,4 @@ with_dict: "{{ docker_registry_services }}" when: - item.value.enabled - - action != 'destroy' + - docker_registry_action != 'destroy' diff --git a/ansible/roles/inspection-store/defaults/main.yml b/ansible/roles/inspection-store/defaults/main.yml index f140f748f..5de75947f 100644 --- a/ansible/roles/inspection-store/defaults/main.yml +++ b/ansible/roles/inspection-store/defaults/main.yml @@ -1,6 +1,10 @@ --- # Roughly follows kolla-ansible's service deployment patterns. +# Action to perform. One of 'deploy', 'destroy', 'pull', 'reconfigure', +# 'upgrade'. +inspection_store_action: deploy + # Whether an inspection store is enabled. inspection_store_enabled: true diff --git a/ansible/roles/inspection-store/tasks/main.yml b/ansible/roles/inspection-store/tasks/main.yml index b017e8b4a..47165bf07 100644 --- a/ansible/roles/inspection-store/tasks/main.yml +++ b/ansible/roles/inspection-store/tasks/main.yml @@ -1,2 +1,2 @@ --- -- include: "{{ action }}.yml" +- include: "{{ inspection_store_action }}.yml" diff --git a/ansible/roles/inspection-store/tasks/pull.yml b/ansible/roles/inspection-store/tasks/pull.yml index 5c0fa23e7..1b00c90b4 100644 --- a/ansible/roles/inspection-store/tasks/pull.yml +++ b/ansible/roles/inspection-store/tasks/pull.yml @@ -7,4 +7,4 @@ with_dict: "{{ inspection_store_services }}" when: - item.value.enabled - - action != 'destroy' + - inspection_store_action != 'destroy' diff --git a/ansible/roles/node-exporter/defaults/main.yml b/ansible/roles/node-exporter/defaults/main.yml index e7cb4398b..37d909772 100644 --- a/ansible/roles/node-exporter/defaults/main.yml +++ b/ansible/roles/node-exporter/defaults/main.yml @@ -1,6 +1,10 @@ --- # Roughly follows kolla-ansible's service deployment patterns. +# Action to perform. One of 'deploy', 'destroy', 'pull', 'reconfigure', +# 'upgrade'. +nodeexporter_action: deploy + # Whether Node Exporter is enabled. nodeexporter_enabled: false diff --git a/ansible/roles/node-exporter/tasks/main.yml b/ansible/roles/node-exporter/tasks/main.yml index b017e8b4a..4fdd4df70 100644 --- a/ansible/roles/node-exporter/tasks/main.yml +++ b/ansible/roles/node-exporter/tasks/main.yml @@ -1,2 +1,2 @@ --- -- include: "{{ action }}.yml" +- include: "{{ nodeexporter_action }}.yml" diff --git a/ansible/roles/node-exporter/tasks/pull.yml b/ansible/roles/node-exporter/tasks/pull.yml index 6e250a764..d9a3b8a55 100644 --- a/ansible/roles/node-exporter/tasks/pull.yml +++ b/ansible/roles/node-exporter/tasks/pull.yml @@ -7,4 +7,4 @@ with_dict: "{{ nodeexporter_services }}" when: - item.value.enabled - - action != 'destroy' + - nodeexporter_action != 'destroy' diff --git a/ansible/roles/opensm/defaults/main.yml b/ansible/roles/opensm/defaults/main.yml index ec568c287..0880822fb 100644 --- a/ansible/roles/opensm/defaults/main.yml +++ b/ansible/roles/opensm/defaults/main.yml @@ -1,6 +1,10 @@ --- # Roughly follows kolla-ansible's service deployment patterns. +# Action to perform. One of 'deploy', 'destroy', 'pull', 'reconfigure', +# 'upgrade'. +opensm_action: deploy + # Whether OpenSM is enabled. opensm_enabled: true diff --git a/ansible/roles/opensm/tasks/main.yml b/ansible/roles/opensm/tasks/main.yml index b017e8b4a..931d389c8 100644 --- a/ansible/roles/opensm/tasks/main.yml +++ b/ansible/roles/opensm/tasks/main.yml @@ -1,2 +1,2 @@ --- -- include: "{{ action }}.yml" +- include: "{{ opensm_action }}.yml" diff --git a/ansible/roles/opensm/tasks/pull.yml b/ansible/roles/opensm/tasks/pull.yml index 523c8a7d7..bc23636e1 100644 --- a/ansible/roles/opensm/tasks/pull.yml +++ b/ansible/roles/opensm/tasks/pull.yml @@ -7,4 +7,4 @@ with_dict: "{{ opensm_services }}" when: - item.value.enabled - - action != 'destroy' + - opensm_action != 'destroy' diff --git a/kayobe/cli/commands.py b/kayobe/cli/commands.py index 065eb2d67..d2c766a7b 100644 --- a/kayobe/cli/commands.py +++ b/kayobe/cli/commands.py @@ -855,7 +855,7 @@ class OvercloudServiceDeploy(KollaAnsibleMixin, KayobeAnsibleMixin, VaultMixin, # Deploy kayobe extra services. playbooks = _build_playbook_list("overcloud-extras") - extra_vars = {"action": "deploy"} + extra_vars = {"kayobe_action": "deploy"} self.run_kayobe_playbooks(parsed_args, playbooks, extra_vars=extra_vars) @@ -912,7 +912,7 @@ class OvercloudServiceReconfigure(KollaAnsibleMixin, KayobeAnsibleMixin, # Reconfigure kayobe extra services. playbooks = _build_playbook_list("overcloud-extras") - extra_vars = {"action": "reconfigure"} + extra_vars = {"kayobe_action": "reconfigure"} self.run_kayobe_playbooks(parsed_args, playbooks, extra_vars=extra_vars) @@ -965,7 +965,7 @@ class OvercloudServiceUpgrade(KollaAnsibleMixin, KayobeAnsibleMixin, # Upgrade kayobe extra services. playbooks = _build_playbook_list("overcloud-extras") - extra_vars = {"action": "upgrade"} + extra_vars = {"kayobe_action": "upgrade"} self.run_kayobe_playbooks(parsed_args, playbooks, extra_vars=extra_vars) @@ -1011,7 +1011,7 @@ class OvercloudServiceDestroy(KollaAnsibleMixin, KayobeAnsibleMixin, # Destroy kayobe extra services. playbooks = _build_playbook_list("overcloud-extras") - extra_vars = {"action": "destroy"} + extra_vars = {"kayobe_action": "destroy"} self.run_kayobe_playbooks(parsed_args, playbooks, extra_vars=extra_vars) @@ -1032,7 +1032,7 @@ class OvercloudContainerImagePull(KayobeAnsibleMixin, KollaAnsibleMixin, # Pull container images for kayobe extra services. playbooks = _build_playbook_list("overcloud-extras") - extra_vars = {"action": "pull"} + extra_vars = {"kayobe_action": "pull"} self.run_kayobe_playbooks(parsed_args, playbooks, extra_vars=extra_vars)