From ccbe248b5d96f0686aeb6e5f1b0b8edc1d035c2b Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Tue, 2 May 2017 11:21:44 -0500 Subject: [PATCH] Clean up cron if l3ha legacy tool is not enabled Related-Bug: 1687447 Change-Id: I13a5d6d0153174959196b6a35f3c79826a15d69c Signed-off-by: Kevin Carter --- tasks/main.yml | 1 - tasks/neutron_l3_ha.yml | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index a780eaeb..a2bb9b8b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -89,7 +89,6 @@ - include: neutron_l3_ha.yml when: - neutron_services['neutron-l3-agent']['group'] in group_names - - neutron_legacy_ha_tool_enabled | bool tags: - neutron-config diff --git a/tasks/neutron_l3_ha.yml b/tasks/neutron_l3_ha.yml index 4d3885e0..c1396159 100644 --- a/tasks/neutron_l3_ha.yml +++ b/tasks/neutron_l3_ha.yml @@ -25,17 +25,23 @@ mode: "0755" tags: - neutron-install + when: + - neutron_legacy_ha_tool_enabled | bool - name: Convert the hostname to an int name2int: name: "{{ inventory_hostname }}" register: hashed_name + when: + - neutron_legacy_ha_tool_enabled | bool # These are used in the Neutron HA Cron job script, and processed in the template. - name: Creating Job Facts set_fact: do_job: ". /root/openrc && /opt/neutron-ha-tool.py {% if keystone_service_internaluri_insecure | bool %}--insecure {% endif %}--l3-agent-migrate" sleep_time: "{{ hashed_name.int_value }}" + when: + - neutron_legacy_ha_tool_enabled | bool - name: "Drop Neutron HA job script" template: @@ -44,6 +50,8 @@ owner: "root" group: "root" mode: "0755" + when: + - neutron_legacy_ha_tool_enabled | bool - name: Create Neutron HA cron: @@ -52,7 +60,17 @@ day: "*" hour: "*" month: "*" - state: present + state: "{{ (neutron_legacy_ha_tool_enabled | bool) | ternary('present', 'absent') }}" job: "/opt/neutron-ha-tool.sh" user: root cron_file: "neutron-ha-tool" + +- name: "Remove AT&T neutron ha tool when disabled" + file: + path: "{{ item }}" + state: "absent" + with_items: + - "/opt/neutron-ha-tool.py" + - "/opt/neutron-ha-tool.sh" + when: + - not neutron_legacy_ha_tool_enabled | bool \ No newline at end of file