From 49c0ca3a9cc5ba3874aeb7b5fd2215750a1e25bc Mon Sep 17 00:00:00 2001
From: zhuzeyu <zhu.zeyu@zte.com.cn>
Date: Wed, 7 Dec 2016 10:43:38 +0800
Subject: [PATCH] Optimize the code

make bool filter more consistence between all roles.

TrivialFix

Change-Id: Icd51749039b1448e09a4713da093b16f965f9ed8
---
 ansible/roles/baremetal/tasks/post-install.yml | 14 +++++++-------
 ansible/roles/baremetal/tasks/pre-install.yml  | 16 ++++++++--------
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/ansible/roles/baremetal/tasks/post-install.yml b/ansible/roles/baremetal/tasks/post-install.yml
index f745776626..9e00696300 100644
--- a/ansible/roles/baremetal/tasks/post-install.yml
+++ b/ansible/roles/baremetal/tasks/post-install.yml
@@ -44,7 +44,7 @@
   become: True
   when:
     - ansible_distribution == "Ubuntu"
-    - apparmor_libvirtd_profile.stat.exists == True
+    - apparmor_libvirtd_profile.stat.exists | bool
 
 - name: Create docker group
   group:
@@ -57,29 +57,29 @@
      append: yes
      groups: docker
   become: True
-  when: create_kolla_user | bool == True
+  when: create_kolla_user | bool
 
 - name: Start docker
   service:
      name: docker
      state: started
-  become: yes
+  become: True
 
 - name: Restart docker
   service:
      name: docker
      state: restarted
-  become: yes
+  become: True
 
 - name: Enable docker
   service:
      name: docker
      enabled: yes
-  become: yes
+  become: True
 
 - name: Reboot
   command: reboot -f
-  become: yes
+  become: True
   when:
    - reboot_required is defined
-   - reboot_required | bool == true
+   - reboot_required | bool
diff --git a/ansible/roles/baremetal/tasks/pre-install.yml b/ansible/roles/baremetal/tasks/pre-install.yml
index 6f567f3193..470c08b406 100644
--- a/ansible/roles/baremetal/tasks/pre-install.yml
+++ b/ansible/roles/baremetal/tasks/pre-install.yml
@@ -1,7 +1,7 @@
 ---
 # NOTE: raw install is required to support cloud images which do not have python installed
 - name: "Install python2 and python-simplejson"
-  become: true
+  become: True
   raw: "yum install -y python python-simplejson || (apt-get update && apt-get install -y python2.7 python-simplejson)"
 
 - name: Gather facts
@@ -14,7 +14,7 @@
     line: "127.0.0.1 localhost"
     state: present
   become: True
-  when: customize_etc_hosts | bool == True
+  when: customize_etc_hosts | bool
 
 - name: Generate /etc/hosts for all of the nodes
   blockinfile:
@@ -25,7 +25,7 @@
           {{ hostvars[host]['ansible_' + hostvars[host]['api_interface']]['ipv4']['address'] }} {{ hostvars[host]['ansible_hostname'] }}
           {% endfor %}
   become: True
-  when: customize_etc_hosts | bool == True
+  when: customize_etc_hosts | bool
 
 - name: Ensure sudo group is present
   group: name=sudo state=present
@@ -34,7 +34,7 @@
 - name: Ensure kolla group is present
   group: name=kolla state=present
   become: True
-  when: create_kolla_user | bool == True
+  when: create_kolla_user | bool
 
 - name: Create kolla user
   user:
@@ -43,7 +43,7 @@
     group: kolla
     groups: "sudo"
   become: True
-  when: create_kolla_user | bool == True
+  when: create_kolla_user | bool
 
 - name: Grant kolla user passwordless sudo
   lineinfile:
@@ -52,14 +52,14 @@
     regexp: '^kolla'
     line: 'kolla ALL=(ALL) NOPASSWD: ALL'
   become: True
-  when: create_kolla_user | bool == True
+  when: create_kolla_user | bool
 
 - name: Add public key to kolla user authorized keys
   authorized_key:
     user: kolla
     key: "{{ kolla_ssh_key.public_key }}"
   become: True
-  when: create_kolla_user | bool == True
+  when: create_kolla_user | bool
 
 - name: Install apt packages
   command: apt-get update
@@ -125,7 +125,7 @@
     group: kolla
     mode: 0755
   become: True
-  when: create_kolla_user | bool == True
+  when: create_kolla_user | bool
 
 - name: Ensure /etc/kolla directory exists
   file:
-- 
GitLab