From 15d4a21f4a328aca970d2c8948c571fb6e345f6a Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Thu, 12 Jul 2018 16:44:21 +0200 Subject: [PATCH] Fix usage of "|" for tests With the more recent versions of ansible, we should now use "is" instead of the "|" sign for the tests. This should fix it. Change-Id: I7ba6ca7d7c8a9bbaf85933370d0ced9931f9a34b --- handlers/main.yml | 2 +- tasks/lxc_cache_preparation_systemd_new.yml | 2 +- tasks/lxc_cache_prestage.yml | 2 +- tasks/lxc_container_btrfs.yml | 2 +- tasks/lxc_container_lvm.yml | 2 +- tasks/lxc_container_overlayfs.yml | 2 +- tasks/lxc_container_zfs.yml | 2 +- tasks/lxc_install_apt.yml | 2 +- tasks/lxc_install_dnf.yml | 128 +++++++++++++++++++- tasks/lxc_install_yum.yml | 10 +- tasks/lxc_install_zypper.yml | 2 +- tasks/lxc_selinux.yml | 2 +- 12 files changed, 142 insertions(+), 16 deletions(-) mode change 120000 => 100644 tasks/lxc_install_dnf.yml diff --git a/handlers/main.yml b/handlers/main.yml index 15f59af9..1f606468 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -101,6 +101,6 @@ enabled: "yes" daemon_reload: yes register: _lxc_dnsmasq_systemd - until: _lxc_dnsmasq_systemd | success + until: _lxc_dnsmasq_systemd is success retries: 5 delay: 5 diff --git a/tasks/lxc_cache_preparation_systemd_new.yml b/tasks/lxc_cache_preparation_systemd_new.yml index 2b049d92..dcaa248e 100644 --- a/tasks/lxc_cache_preparation_systemd_new.yml +++ b/tasks/lxc_cache_preparation_systemd_new.yml @@ -38,7 +38,7 @@ /tmp/{{ cache_basename }} {{ lxc_container_base_name }} register: pull_image - until: pull_image | success + until: pull_image is success retries: 3 delay: 1 changed_when: pull_image.rc == 0 diff --git a/tasks/lxc_cache_prestage.yml b/tasks/lxc_cache_prestage.yml index 328b3a3d..697bc7f6 100644 --- a/tasks/lxc_cache_prestage.yml +++ b/tasks/lxc_cache_prestage.yml @@ -33,7 +33,7 @@ register: legacy_image_url retries: 3 delay: 1 - until: legacy_image_url | success + until: legacy_image_url is success - name: Set LXC cache fact(s) (legacy) set_fact: diff --git a/tasks/lxc_container_btrfs.yml b/tasks/lxc_container_btrfs.yml index 8dc38c81..1533cbbd 100644 --- a/tasks/lxc_container_btrfs.yml +++ b/tasks/lxc_container_btrfs.yml @@ -23,7 +23,7 @@ register: cache_download retries: 3 delay: 10 - until: cache_download|success + until: cache_download is success - name: Set the qgroup limits block: diff --git a/tasks/lxc_container_lvm.yml b/tasks/lxc_container_lvm.yml index 143d156b..25b4cc4b 100644 --- a/tasks/lxc_container_lvm.yml +++ b/tasks/lxc_container_lvm.yml @@ -23,7 +23,7 @@ register: cache_download retries: 3 delay: 10 - until: cache_download|success + until: cache_download is success when: - lxc_container_backing_method is defined - lxc_container_backing_method == 'copy-on-write' diff --git a/tasks/lxc_container_overlayfs.yml b/tasks/lxc_container_overlayfs.yml index 35bd4de0..e16cc4f1 100644 --- a/tasks/lxc_container_overlayfs.yml +++ b/tasks/lxc_container_overlayfs.yml @@ -23,4 +23,4 @@ register: cache_download retries: 3 delay: 10 - until: cache_download|success + until: cache_download is success diff --git a/tasks/lxc_container_zfs.yml b/tasks/lxc_container_zfs.yml index cf8832ef..24010dec 100644 --- a/tasks/lxc_container_zfs.yml +++ b/tasks/lxc_container_zfs.yml @@ -24,4 +24,4 @@ register: cache_download retries: 3 delay: 10 - until: cache_download|success + until: cache_download is success diff --git a/tasks/lxc_install_apt.yml b/tasks/lxc_install_apt.yml index ba71c919..f3ecea18 100644 --- a/tasks/lxc_install_apt.yml +++ b/tasks/lxc_install_apt.yml @@ -29,7 +29,7 @@ update_cache: yes cache_valid_time: "{{ cache_timeout }}" register: install_packages - until: install_packages|success + until: install_packages is success retries: 5 delay: 2 tags: diff --git a/tasks/lxc_install_dnf.yml b/tasks/lxc_install_dnf.yml deleted file mode 120000 index 850505a0..00000000 --- a/tasks/lxc_install_dnf.yml +++ /dev/null @@ -1 +0,0 @@ -lxc_install_yum.yml \ No newline at end of file diff --git a/tasks/lxc_install_dnf.yml b/tasks/lxc_install_dnf.yml new file mode 100644 index 00000000..d3e2e9e6 --- /dev/null +++ b/tasks/lxc_install_dnf.yml @@ -0,0 +1,127 @@ +--- +# Copyright 2016, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Ensure createrepo package is installed + yum: + name: createrepo + state: latest + +- name: Deploy upstream COPR yum repo for LXC 2.0 + yum_repository: + name: thm-lxc2.0 + description: "COPR repository for LXC 2.0 packages on CentOS 7" + baseurl: "{{ lxc_centos_package_baseurl }}" + enabled: no + gpgcheck: yes + gpgkey: "{{ lxc_centos_package_key }}" + repo_gpgcheck: no + priority: 99 + state: present + +- name: Deploy local COPR yum repo for LXC 2.0 + yum_repository: + name: thm-lxc2.0-local + description: "Local repository for LXC 2.0 packages on CentOS 7" + baseurl: "file:///opt/thm-lxc2.0" + enabled: no + gpgcheck: yes + gpgkey: "{{ lxc_centos_package_key }}" + repo_gpgcheck: no + priority: 99 + state: present + register: copr_repository_deploy + +# NOTE: Existing CentOS environments may not have the COPR repo priority set +# higher than the default. The following task ensures that existing +# deployments have their priority adjusted for the COPR repository. +# NOTE: We need to remove priority settings in S cycle. +# TODO(mhayden): The ini_file module is required here since the yum_repository +# module can only do add/remove operations, not edits. +# Ansible bug: https://github.com/ansible/ansible/issues/22362 +- name: Ensure COPR repository priority is set + ini_file: + dest: /etc/yum.repos.d/thm-lxc2.0.repo + section: thm-lxc2.0 + option: priority + value: 99 + when: + - not copr_repository_deploy is changed + +- name: Add GPG key for COPR LXC repo + rpm_key: + key: "{{ lxc_centos_package_key }}" + state: present + register: add_keys + until: add_keys is success + retries: 5 + delay: 2 + +- name: Create and enable local LXC package repository + command: "{{ item }}" + with_items: + - "reposync --repoid=thm-lxc2.0 --download_path=/tmp/" + - "createrepo /tmp/thm-lxc2.0" + - "rsync -a --delete /tmp/thm-lxc2.0/ /opt/thm-lxc2.0/" + - "yum-config-manager --enable thm-lxc2.0-local" + +- name: Install EPEL gpg keys + rpm_key: + key: "http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7" + state: present + register: _add_yum_keys + until: _add_yum_keys is success + retries: 5 + delay: 2 + +- name: Install the EPEL repository + yum_repository: + name: epel-lxc_hosts + baseurl: "{{ (centos_epel_mirror | default ('http://download.fedoraproject.org/pub/epel')) ~ '/' ~ ansible_distribution_major_version ~ '/' ~ ansible_architecture }}" + description: 'Extra Packages for Enterprise Linux 7 - $basearch' + gpgcheck: yes + enabled: yes + state: present + includepkgs: 'aria2 python2-lxc' + register: install_epel_repo + until: install_epel_repo is success + retries: 5 + delay: 2 + +- name: Install distro packages + package: + pkg: "{{ lxc_hosts_distro_packages }}" + state: "{{ lxc_hosts_package_state }}" + register: install_packages + until: install_packages is success + retries: 5 + delay: 2 + tags: + - lxc-packages + +- name: Remove sub system lock if found + file: + path: "/var/lock/subsys/lxc" + state: "absent" + owner: "root" + group: "root" + tags: + - lxc-directories + +- name: Enable lxc service + service: + name: lxc + enabled: "yes" + tags: + - lxc_hosts-config diff --git a/tasks/lxc_install_yum.yml b/tasks/lxc_install_yum.yml index 631797df..d3e2e9e6 100644 --- a/tasks/lxc_install_yum.yml +++ b/tasks/lxc_install_yum.yml @@ -57,14 +57,14 @@ option: priority value: 99 when: - - not copr_repository_deploy | changed + - not copr_repository_deploy is changed - name: Add GPG key for COPR LXC repo rpm_key: key: "{{ lxc_centos_package_key }}" state: present register: add_keys - until: add_keys | success + until: add_keys is success retries: 5 delay: 2 @@ -81,7 +81,7 @@ key: "http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7" state: present register: _add_yum_keys - until: _add_yum_keys | success + until: _add_yum_keys is success retries: 5 delay: 2 @@ -95,7 +95,7 @@ state: present includepkgs: 'aria2 python2-lxc' register: install_epel_repo - until: install_epel_repo|success + until: install_epel_repo is success retries: 5 delay: 2 @@ -104,7 +104,7 @@ pkg: "{{ lxc_hosts_distro_packages }}" state: "{{ lxc_hosts_package_state }}" register: install_packages - until: install_packages|success + until: install_packages is success retries: 5 delay: 2 tags: diff --git a/tasks/lxc_install_zypper.yml b/tasks/lxc_install_zypper.yml index 0fcaa87e..e926b632 100644 --- a/tasks/lxc_install_zypper.yml +++ b/tasks/lxc_install_zypper.yml @@ -30,7 +30,7 @@ name: "{{ lxc_hosts_distro_packages }}" state: "{{ lxc_hosts_package_state }}" register: install_packages - until: install_packages|success + until: install_packages is success retries: 5 delay: 2 tags: diff --git a/tasks/lxc_selinux.yml b/tasks/lxc_selinux.yml index 08955f3c..e0f3d602 100644 --- a/tasks/lxc_selinux.yml +++ b/tasks/lxc_selinux.yml @@ -61,4 +61,4 @@ when: - openstack_log_dir.stat.exists - '"/openstack/log" not in fcontext_check.stdout' - - selinux_equivalence | changed + - selinux_equivalence is changed