diff --git a/defaults/main.yml b/defaults/main.yml index 1aed7426..78b85613 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -43,7 +43,7 @@ lxc_host_machine_volume_size: |- {%- set mounts = [] -%} {%- set mount_points = ['/var/lib/machines', '/var/lib/', '/var', '/'] -%} {%- for mount in mount_points -%} - {%- for dev in ansible_mounts -%} + {%- for dev in ansible_facts['mounts'] -%} {%- if mount == dev.mount -%} {%- set _ = mounts.append(dev.size_total // (1024 ** 3)) -%} {%- endif -%} @@ -246,7 +246,7 @@ lxc_cache_locales: "{{ _lxc_cache_locales | default(['en_US.UTF-8']) }}" # Centos EPEL repository options lxc_centos_epel_mirror: "{{ centos_epel_mirror | default('http://download.fedoraproject.org/pub/epel') }}" -lxc_centos_epel_key: "{{ centos_epel_key | default('http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-' ~ ansible_distribution_major_version) }}" +lxc_centos_epel_key: "{{ centos_epel_key | default('http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-' ~ ansible_facts['distribution_major_version']) }}" # LXC must be installed from a COPR repository on CentOS since the version # provided in EPEL is much too old (1.x). diff --git a/meta/main.yml b/meta/main.yml index cf927ca7..12ca26e3 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -35,4 +35,4 @@ galaxy_info: dependencies: - role: apt_package_pinning when: - - ansible_pkg_mgr == 'apt' + - ansible_facts['pkg_mgr'] == 'apt' diff --git a/tasks/lxc_cache.yml b/tasks/lxc_cache.yml index 6f7015b8..0d046966 100644 --- a/tasks/lxc_cache.yml +++ b/tasks/lxc_cache.yml @@ -16,7 +16,7 @@ - name: Set LXC cache fact(s) set_fact: cache_path_fact: "{{ lxc_container_cache_path }}/{{ lxc_cache_map.distro }}/{{ lxc_cache_map.release }}/{{ lxc_cache_map.arch }}/{{ lxc_cache_default_variant }}" - cache_time: "{{ ansible_date_time.epoch }}" + cache_time: "{{ ansible_facts['date_time']['epoch'] }}" - name: Retrieve the expiry object slurp: diff --git a/tasks/lxc_cache_preparation.yml b/tasks/lxc_cache_preparation.yml index eaa18ac3..a756f201 100644 --- a/tasks/lxc_cache_preparation.yml +++ b/tasks/lxc_cache_preparation.yml @@ -96,7 +96,7 @@ mode: "0440" src: sudoers.j2 when: - - ansible_pkg_mgr == 'yum' + - ansible_facts['pkg_mgr'] == 'yum' - name: Adjust sshd configuration in container lineinfile: diff --git a/tasks/lxc_install_dnf.yml b/tasks/lxc_install_dnf.yml index ecda01b1..e42256b7 100644 --- a/tasks/lxc_install_dnf.yml +++ b/tasks/lxc_install_dnf.yml @@ -58,8 +58,8 @@ - name: Install the EPEL repository - Centos-8 yum_repository: name: epel-lxc_hosts - baseurl: "{{ lxc_centos_epel_mirror ~ '/' ~ ansible_distribution_major_version ~ '/Everything/' ~ ansible_architecture }}" - description: 'Extra Packages for Enterprise Linux {{ ansible_distribution_major_version }} - $basearch' + baseurl: "{{ lxc_centos_epel_mirror ~ '/' ~ ansible_facts['distribution_major_version'] ~ '/Everything/' ~ ansible_facts['architecture'] }}" + description: "Extra Packages for Enterprise Linux {{ ansible_facts['distribution_major_version'] }} - $basearch" gpgcheck: yes gpgkey: "file:///etc/pki/rpm-gpg/{{ lxc_centos_epel_key.split('/')[-1] }}" enabled: yes diff --git a/tasks/lxc_net.yml b/tasks/lxc_net.yml index 1ab741bf..9a7fd4cd 100644 --- a/tasks/lxc_net.yml +++ b/tasks/lxc_net.yml @@ -83,7 +83,7 @@ line: "source /etc/network/interfaces.d/*.cfg" backup: "yes" when: - - ansible_os_family == "Debian" + - ansible_facts['os_family'] == "Debian" tags: - lxc-net - lxc-interfaces diff --git a/tasks/lxc_post_install.yml b/tasks/lxc_post_install.yml index 95fd0475..31504a0d 100644 --- a/tasks/lxc_post_install.yml +++ b/tasks/lxc_post_install.yml @@ -57,7 +57,7 @@ regexp: "^.*DefaultTasksMax.*$" line: "DefaultTasksMax={{ lxc_default_tasks_max }}" when: - - ansible_service_mgr == 'systemd' + - ansible_facts['service_mgr'] == 'systemd' notify: - Reload systemd units tags: diff --git a/tasks/main.yml b/tasks/main.yml index cb0cc3e3..f4fcd3d9 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -34,11 +34,11 @@ - name: Gather variables for each operating system include_vars: "{{ item }}" with_first_found: - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}-host.yml" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}-host.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}-host.yml" - - "{{ ansible_distribution | lower }}-host.yml" - - "{{ ansible_os_family | lower }}-host.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}-host.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}-host.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}-host.yml" + - "{{ ansible_facts['distribution'] | lower }}-host.yml" + - "{{ ansible_facts['os_family'] | lower }}-host.yml" tags: - always @@ -46,11 +46,11 @@ include_vars: "{{ item }}" with_first_found: - "{{ lxc_user_defined_container | default([]) }}" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - - "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - - "{{ ansible_distribution | lower }}.yml" - - "{{ ansible_os_family | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}.yml" tags: - always @@ -58,7 +58,7 @@ tags: - lxc_hosts-install -- include_tasks: "lxc_install_{{ ansible_pkg_mgr }}.yml" +- include_tasks: "lxc_install_{{ ansible_facts['pkg_mgr'] }}.yml" tags: - lxc_hosts-install @@ -82,7 +82,3 @@ - name: Flush handlers meta: flush_handlers - -- name: (RE)Gather facts post setup - setup: - gather_subset: "network,hardware,virtual" diff --git a/templates/prep-scripts/debian_prep.sh.j2 b/templates/prep-scripts/debian_prep.sh.j2 index b3598ba7..69f9785b 100644 --- a/templates/prep-scripts/debian_prep.sh.j2 +++ b/templates/prep-scripts/debian_prep.sh.j2 @@ -16,7 +16,7 @@ apt-get remove -y --purge snap* lxc* lxd* resolvconf* || true apt-get update apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes eatmydata -export LD_PRELOAD=/usr/lib/{{ ansible_architecture }}-linux-gnu/libeatmydata.so +export LD_PRELOAD=/usr/lib/{{ ansible_facts['architecture'] }}-linux-gnu/libeatmydata.so apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes gnupg apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes diff --git a/templates/prep-scripts/ubuntu_18_prep.sh.j2 b/templates/prep-scripts/ubuntu_18_prep.sh.j2 index ff4c3b10..6ab5ee02 100644 --- a/templates/prep-scripts/ubuntu_18_prep.sh.j2 +++ b/templates/prep-scripts/ubuntu_18_prep.sh.j2 @@ -14,7 +14,7 @@ apt-get remove -y --purge snap* lxc* lxd* resolvconf* || true apt-get update apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes eatmydata -export LD_PRELOAD=/usr/lib/{{ ansible_architecture }}-linux-gnu/libeatmydata.so +export LD_PRELOAD=/usr/lib/{{ ansible_facts['architecture'] }}-linux-gnu/libeatmydata.so apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes gnupg apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes diff --git a/templates/prep-scripts/ubuntu_20_prep.sh.j2 b/templates/prep-scripts/ubuntu_20_prep.sh.j2 index ff4c3b10..6ab5ee02 100644 --- a/templates/prep-scripts/ubuntu_20_prep.sh.j2 +++ b/templates/prep-scripts/ubuntu_20_prep.sh.j2 @@ -14,7 +14,7 @@ apt-get remove -y --purge snap* lxc* lxd* resolvconf* || true apt-get update apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes eatmydata -export LD_PRELOAD=/usr/lib/{{ ansible_architecture }}-linux-gnu/libeatmydata.so +export LD_PRELOAD=/usr/lib/{{ ansible_facts['architecture'] }}-linux-gnu/libeatmydata.so apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes gnupg apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes diff --git a/tests/test.yml b/tests/test.yml index 694a031d..3de85351 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -29,11 +29,11 @@ apt: update_cache: yes when: - - ansible_pkg_mgr == 'apt' + - ansible_facts['pkg_mgr'] == 'apt' - name: Ensure root ssh key user: - name: "{{ ansible_env.USER | default('root') }}" + name: "{{ ansible_facts['env']['USER'] | default('root') }}" generate_ssh_key: "yes" ssh_key_bits: 2048 ssh_key_file: ".ssh/id_rsa" @@ -85,12 +85,12 @@ - name: DEBIAN - Get deployed interface file contents, without Ansible managed line set_fact: interface_file: "{{ lookup('pipe', 'cat /etc/network/interfaces.d/lxc-net-bridge.cfg | tail -n +3') }}" - when: ansible_os_family | lower == "debian" + when: ansible_facts['os_family'] | lower == "debian" - name: RHEL - Get deployed interface file contents, without Ansible managed line set_fact: interface_file: "{{ lookup('pipe', 'cat /etc/sysconfig/network-scripts/ifcfg-lxcbr0 | tail -n +3') }}" - when: ansible_os_family | lower == "redhat" + when: ansible_facts['os_family'] | lower == "redhat" - name: Get bridge interface facts setup: diff --git a/vars/debian.yml b/vars/debian.yml index d42f472f..756023d4 100644 --- a/vars/debian.yml +++ b/vars/debian.yml @@ -13,12 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -_lxc_hosts_container_image_url: "https://github.com/debuerreotype/docker-debian-artifacts/raw/dist-{{ lxc_cache_map.arch }}/{{ ansible_distribution_release }}/rootfs.tar.xz" +_lxc_hosts_container_image_url: "https://github.com/debuerreotype/docker-debian-artifacts/raw/dist-{{ lxc_cache_map.arch }}/{{ ansible_facts['distribution_release'] }}/rootfs.tar.xz" _lxc_cache_map: distro: debian - arch: "{{ lxc_architecture_mapping.get( ansible_architecture ) }}" - release: "{{ ansible_distribution_major_version }}" + arch: "{{ lxc_architecture_mapping.get( ansible_facts['architecture'] ) }}" + release: "{{ ansible_facts['distribution_major_version'] }}" copy_from_host: - /etc/apt/sources.list - /etc/apt/apt.conf.d/ diff --git a/vars/redhat.yml b/vars/redhat.yml index e8592660..7cac309b 100644 --- a/vars/redhat.yml +++ b/vars/redhat.yml @@ -28,7 +28,7 @@ _lxc_hosts_unarchive_extra_opts: _lxc_cache_map: distro: centos - arch: "{{ lxc_architecture_mapping.get( ansible_architecture ) }}" + arch: "{{ lxc_architecture_mapping.get( ansible_facts['architecture'] ) }}" release: 8 copy_from_host: - /etc/default/locale diff --git a/vars/ubuntu-18.04.yml b/vars/ubuntu-18.04.yml index fba7c65a..9e9b3181 100644 --- a/vars/ubuntu-18.04.yml +++ b/vars/ubuntu-18.04.yml @@ -19,7 +19,7 @@ _lxc_hosts_container_image_checksum_regexp: "ubuntu-base-18.04.[0-9]-base-{{ lxc _lxc_cache_map: distro: ubuntu - arch: "{{ lxc_architecture_mapping.get( ansible_architecture ) }}" + arch: "{{ lxc_architecture_mapping.get( ansible_facts['architecture'] ) }}" release: bionic copy_from_host: - /etc/apt/sources.list diff --git a/vars/ubuntu-20.04.yml b/vars/ubuntu-20.04.yml index 4f04e72a..63f0abfc 100644 --- a/vars/ubuntu-20.04.yml +++ b/vars/ubuntu-20.04.yml @@ -19,7 +19,7 @@ _lxc_hosts_container_image_checksum_regexp: "ubuntu-base-20.04.[0-9]-base-{{ lxc _lxc_cache_map: distro: ubuntu - arch: "{{ lxc_architecture_mapping.get( ansible_architecture ) }}" + arch: "{{ lxc_architecture_mapping.get( ansible_facts['architecture'] ) }}" release: focal copy_from_host: - /etc/apt/sources.list