From aa0209c9a41b2c6b771c1fd8a972e68eecd87e7e Mon Sep 17 00:00:00 2001 From: Eduardo Gonzalez Date: Tue, 19 Sep 2017 11:23:20 +0200 Subject: [PATCH] Unify global syntax in baremetal role Baremetal roles does not keep common sytax used in rest of the roles, even it baremetal role some tasks differs in syntax with each others. Change-Id: Ib04fe123501e2a3e829176953f20719a253999d3 --- ansible/roles/baremetal/tasks/install.yml | 31 ++++++++++++++----- .../roles/baremetal/tasks/post-install.yml | 13 ++++---- ansible/roles/baremetal/tasks/pre-install.yml | 22 ++++++++++--- .../baremetal/templates/docker_apt_repo.j2 | 2 +- .../baremetal/templates/docker_defaults.j2 | 2 +- .../baremetal/templates/docker_yum_repo.j2 | 4 +-- 6 files changed, 51 insertions(+), 23 deletions(-) diff --git a/ansible/roles/baremetal/tasks/install.yml b/ansible/roles/baremetal/tasks/install.yml index 0065f74104..71ea50efc0 100644 --- a/ansible/roles/baremetal/tasks/install.yml +++ b/ansible/roles/baremetal/tasks/install.yml @@ -7,7 +7,9 @@ # TODO(inc0): Gates don't seem to have ufw executable, check for it instead of ignore errors - name: Set firewall default policy become: True - ufw: state=disabled policy=allow + ufw: + state: disabled + policy: allow when: ansible_os_family == 'Debian' ignore_errors: yes @@ -30,40 +32,53 @@ - firewalld_check.rc == 0 - name: Install apt packages - package: name={{item}} state=present + package: + name: "{{ item }}" + state: present become: True with_items: "{{ debian_pkg_install }}" when: ansible_os_family == 'Debian' - name: Install deltarpm packages - package: name={{item}} state=installed + package: + name: "{{ item }}" + state: installed become: True with_items: - deltarpm when: ansible_os_family == 'RedHat' - name: Install yum packages - package: name={{item}} state=present + package: + name: "{{ item }}" + state: present become: True with_items: "{{ redhat_pkg_install }}" when: ansible_os_family == 'RedHat' - name: Install pip - easy_install: name=pip + easy_install: + name: pip become: True - name: Install docker SDK for python - pip: name=docker state=latest + pip: + name: docker + state: latest become: True - name: Remove packages - package: name={{item}} state=absent + package: + name: "{{ item }}" + state: absent with_items: "{{ ubuntu_pkg_removals }}" become: True when: ansible_distribution|lower == "ubuntu" - name: Remove packages - package: name={{item}} state=absent + package: + name: "{{ item }}" + state: absent with_items: "{{ redhat_pkg_removals }}" become: True when: ansible_os_family == 'RedHat' diff --git a/ansible/roles/baremetal/tasks/post-install.yml b/ansible/roles/baremetal/tasks/post-install.yml index 64fc6f3a5f..ed222ade84 100644 --- a/ansible/roles/baremetal/tasks/post-install.yml +++ b/ansible/roles/baremetal/tasks/post-install.yml @@ -1,16 +1,16 @@ --- - name: Ensure docker service directory exists file: - path=/etc/systemd/system/docker.service.d - state=directory - recurse=yes + path: /etc/systemd/system/docker.service.d + state: directory + recurse: yes become: True - name: Configure docker service become: True template: - src=docker_systemd_service.j2 - dest=/etc/systemd/system/docker.service.d/kolla.conf + src: docker_systemd_service.j2 + dest: /etc/systemd/system/docker.service.d/kolla.conf register: docker_configured - name: Reload docker service file @@ -18,7 +18,8 @@ command: systemctl daemon-reload - name: Get stat of libvirtd apparmor profile - stat: path=/etc/apparmor.d/usr.sbin.libvirtd + stat: + path: /etc/apparmor.d/usr.sbin.libvirtd register: apparmor_libvirtd_profile when: ansible_distribution == "Ubuntu" diff --git a/ansible/roles/baremetal/tasks/pre-install.yml b/ansible/roles/baremetal/tasks/pre-install.yml index 3818c9b2c2..1465612ce9 100644 --- a/ansible/roles/baremetal/tasks/pre-install.yml +++ b/ansible/roles/baremetal/tasks/pre-install.yml @@ -35,11 +35,15 @@ 'ansible_' + hostvars[inventory_hostname]['api_interface'] in hostvars[inventory_hostname] - name: Ensure sudo group is present - group: name=sudo state=present + group: + name: sudo + state: present become: True - name: Ensure kolla group is present - group: name=kolla state=present + group: + name: kolla + state: present become: True when: create_kolla_user | bool @@ -74,7 +78,9 @@ when: ansible_os_family == 'Debian' - name: Install ubuntu ca certs - package: name={{item}} state=latest + package: + name: "{{ item }}" + state: latest become: True with_items: - ca-certificates @@ -83,7 +89,10 @@ - ansible_os_family == 'Debian' - name: Ensure apt sources list directory exists - file: path=/etc/apt/sources.list.d state=directory recurse=yes + file: + path: /etc/apt/sources.list.d + state: directory + recurse: yes become: True when: ansible_os_family == 'Debian' @@ -105,7 +114,10 @@ - ansible_distribution == 'Ubuntu' - name: Ensure yum repos directory exists - file: path=/etc/yum.repos.d/ state=directory recurse=yes + file: + path: /etc/yum.repos.d/ + state: directory + recurse: yes become: True when: ansible_os_family == 'RedHat' diff --git a/ansible/roles/baremetal/templates/docker_apt_repo.j2 b/ansible/roles/baremetal/templates/docker_apt_repo.j2 index a317c5b56f..16ea8fc1d7 100644 --- a/ansible/roles/baremetal/templates/docker_apt_repo.j2 +++ b/ansible/roles/baremetal/templates/docker_apt_repo.j2 @@ -1,2 +1,2 @@ # main docker repo -deb {{docker_apt_url}}/repo {{ansible_distribution|lower}}-{{ansible_distribution_release|lower}} main +deb {{ docker_apt_url }}/repo {{ ansible_distribution | lower }}-{{ ansible_distribution_release | lower }} main diff --git a/ansible/roles/baremetal/templates/docker_defaults.j2 b/ansible/roles/baremetal/templates/docker_defaults.j2 index 0b6b375bb5..7ef258f650 100644 --- a/ansible/roles/baremetal/templates/docker_defaults.j2 +++ b/ansible/roles/baremetal/templates/docker_defaults.j2 @@ -16,7 +16,7 @@ DOCKER_OPTS="" DOCKER_OPTS="$DOCKER_OPTS --storage-driver={{ docker_storage_driver }}" {% endif %} {% if docker_registry %} -DOCKER_OPTS="$DOCKER_OPTS --insecure-registry {{ docker_registry }}" +DOCKER_OPTS="$DOCKER_OPTS --insecure-registry {{ docker_registry }}" {% endif %} # If you need Docker to use an HTTP proxy, it can also be specified here. diff --git a/ansible/roles/baremetal/templates/docker_yum_repo.j2 b/ansible/roles/baremetal/templates/docker_yum_repo.j2 index a165efab20..8de5f3703c 100644 --- a/ansible/roles/baremetal/templates/docker_yum_repo.j2 +++ b/ansible/roles/baremetal/templates/docker_yum_repo.j2 @@ -1,6 +1,6 @@ [docker-repo] name=Docker main Repository -baseurl={{docker_yum_url}}/repo/main/{{ansible_distribution|lower}}/{{ansible_distribution_major_version|lower}} +baseurl={{ docker_yum_url }}/repo/main/{{ ansible_distribution | lower }}/{{ ansible_distribution_major_version | lower }} enabled=1 gpgcheck=1 -gpgkey={{docker_yum_url}}/gpg +gpgkey={{ docker_yum_url }}/gpg