From d7495b1d39672f14de7598714984754b8406e5f4 Mon Sep 17 00:00:00 2001 From: Jeffrey Zhang Date: Mon, 21 Mar 2016 00:05:59 +0800 Subject: [PATCH] Fix the prechecks role idempotent the prechecks role should be idempotent and should changed nothing when running. TrivialFix Change-Id: Ib5063d879e0f5f414d607bd9b6493a7499fc5652 --- ansible/roles/prechecks/tasks/package_checks.yml | 2 ++ ansible/roles/prechecks/tasks/service_checks.yml | 3 +++ 2 files changed, 5 insertions(+) diff --git a/ansible/roles/prechecks/tasks/package_checks.yml b/ansible/roles/prechecks/tasks/package_checks.yml index 5c927e63e4..ef8147fd99 100644 --- a/ansible/roles/prechecks/tasks/package_checks.yml +++ b/ansible/roles/prechecks/tasks/package_checks.yml @@ -2,10 +2,12 @@ - name: Checking docker-py version command: python -c "import docker; print docker.__version__" register: result + changed_when: false failed_when: result | failed or result.stdout | version_compare(docker_py_version_min, '<') - name: Checking Ansible version local_action: command ansible --version register: result + changed_when: false failed_when: result.stdout | regex_replace('ansible (\\d+\\.\\d+\\.\\d+)', '\\1') | version_compare(ansible_version_max, '>=') diff --git a/ansible/roles/prechecks/tasks/service_checks.yml b/ansible/roles/prechecks/tasks/service_checks.yml index 8dcbda0fb9..262e6f7149 100644 --- a/ansible/roles/prechecks/tasks/service_checks.yml +++ b/ansible/roles/prechecks/tasks/service_checks.yml @@ -8,12 +8,14 @@ - name: Checking Docker version command: docker version register: result + changed_when: false failed_when: result | failed or (result.stdout | from_yaml).Server.Version | regex_replace('(\\d+\\.\\d+\\.\\d+).*', '\\1') | version_compare(docker_version_min, '<') - name: Checking if 'MountFlags' in /lib/systemd/system/docker.service is set to 'shared' command: cat /lib/systemd/system/docker.service register: result + changed_when: false failed_when: result.stdout.find('MountFlags=shared') == -1 when: - (inventory_hostname in groups['neutron-dhcp-agent'] @@ -25,6 +27,7 @@ - name: Checking if '/run' mount flag is set to 'shared' command: awk '$5 == "/run" {print $7}' /proc/self/mountinfo register: result + changed_when: false failed_when: result.stdout.find('shared') == -1 when: - (inventory_hostname in groups['neutron-dhcp-agent']