Ansible and Python both support actual dictionaries, so make use
of them in the inventory instead of emulating them by using
variable names sharing the same prefix.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
guests/host_vars/libvirt-centos-7/main.yml | 6 ++-
guests/host_vars/libvirt-centos-8/main.yml | 6 ++-
guests/host_vars/libvirt-debian-10/main.yml | 6 ++-
guests/host_vars/libvirt-debian-9/main.yml | 6 ++-
guests/host_vars/libvirt-debian-sid/main.yml | 6 ++-
guests/host_vars/libvirt-fedora-30/main.yml | 6 ++-
guests/host_vars/libvirt-fedora-31/main.yml | 6 ++-
.../host_vars/libvirt-fedora-rawhide/main.yml | 6 ++-
guests/host_vars/libvirt-freebsd-11/main.yml | 6 ++-
guests/host_vars/libvirt-freebsd-12/main.yml | 6 ++-
.../libvirt-freebsd-current/main.yml | 6 ++-
.../host_vars/libvirt-opensuse-151/main.yml | 6 ++-
guests/host_vars/libvirt-ubuntu-1604/main.yml | 6 ++-
guests/host_vars/libvirt-ubuntu-1804/main.yml | 6 ++-
guests/lcitool | 49 ++++++++-----------
guests/playbooks/update/tasks/base.yml | 44 ++++++++---------
guests/playbooks/update/tasks/bootloader.yml | 2 +-
guests/playbooks/update/tasks/gitlab.yml | 2 +-
guests/playbooks/update/tasks/kludges.yml | 8 +--
guests/playbooks/update/tasks/packages.yml | 16 +++---
20 files changed, 112 insertions(+), 93 deletions(-)
diff --git a/guests/host_vars/libvirt-centos-7/main.yml
b/guests/host_vars/libvirt-centos-7/main.yml
index 104b702..ac40c7c 100644
--- a/guests/host_vars/libvirt-centos-7/main.yml
+++ b/guests/host_vars/libvirt-centos-7/main.yml
@@ -15,10 +15,12 @@ projects:
- osinfo-db-tools
- virt-viewer
+os:
+ name: 'CentOS'
+ version: '7'
+
package_format: 'rpm'
package_manager: 'yum'
-os_name: 'CentOS'
-os_version: '7'
bash: /bin/bash
cc: /usr/bin/gcc
diff --git a/guests/host_vars/libvirt-centos-8/main.yml
b/guests/host_vars/libvirt-centos-8/main.yml
index 441802c..77ba6b1 100644
--- a/guests/host_vars/libvirt-centos-8/main.yml
+++ b/guests/host_vars/libvirt-centos-8/main.yml
@@ -15,10 +15,12 @@ projects:
- virt-manager
- virt-viewer
+os:
+ name: 'CentOS'
+ version: '8'
+
package_format: 'rpm'
package_manager: 'dnf'
-os_name: 'CentOS'
-os_version: '8'
bash: /bin/bash
cc: /usr/bin/gcc
diff --git a/guests/host_vars/libvirt-debian-10/main.yml
b/guests/host_vars/libvirt-debian-10/main.yml
index e3aca55..cb859d1 100644
--- a/guests/host_vars/libvirt-debian-10/main.yml
+++ b/guests/host_vars/libvirt-debian-10/main.yml
@@ -17,10 +17,12 @@ projects:
- virt-manager
- virt-viewer
+os:
+ name: 'Debian'
+ version: '10'
+
package_format: 'deb'
package_manager: 'apt-get'
-os_name: 'Debian'
-os_version: '10'
bash: /bin/bash
cc: /usr/bin/gcc
diff --git a/guests/host_vars/libvirt-debian-9/main.yml
b/guests/host_vars/libvirt-debian-9/main.yml
index 0599aa4..c9b739d 100644
--- a/guests/host_vars/libvirt-debian-9/main.yml
+++ b/guests/host_vars/libvirt-debian-9/main.yml
@@ -17,10 +17,12 @@ projects:
- virt-manager
- virt-viewer
+os:
+ name: 'Debian'
+ version: '9'
+
package_format: 'deb'
package_manager: 'apt-get'
-os_name: 'Debian'
-os_version: '9'
bash: /bin/bash
cc: /usr/bin/gcc
diff --git a/guests/host_vars/libvirt-debian-sid/main.yml
b/guests/host_vars/libvirt-debian-sid/main.yml
index 565b0be..6e1adda 100644
--- a/guests/host_vars/libvirt-debian-sid/main.yml
+++ b/guests/host_vars/libvirt-debian-sid/main.yml
@@ -17,10 +17,12 @@ projects:
- virt-manager
- virt-viewer
+os:
+ name: 'Debian'
+ version: 'Sid'
+
package_format: 'deb'
package_manager: 'apt-get'
-os_name: 'Debian'
-os_version: 'Sid'
bash: /bin/bash
cc: /usr/bin/gcc
diff --git a/guests/host_vars/libvirt-fedora-30/main.yml
b/guests/host_vars/libvirt-fedora-30/main.yml
index d31a84a..2a317c3 100644
--- a/guests/host_vars/libvirt-fedora-30/main.yml
+++ b/guests/host_vars/libvirt-fedora-30/main.yml
@@ -30,10 +30,12 @@ projects:
- virt-viewer+mingw32
- virt-viewer+mingw64
+os:
+ name: 'Fedora'
+ version: '30'
+
package_format: 'rpm'
package_manager: 'dnf'
-os_name: 'Fedora'
-os_version: '30'
bash: /bin/bash
cc: /usr/bin/gcc
diff --git a/guests/host_vars/libvirt-fedora-31/main.yml
b/guests/host_vars/libvirt-fedora-31/main.yml
index 389cfac..ade64ed 100644
--- a/guests/host_vars/libvirt-fedora-31/main.yml
+++ b/guests/host_vars/libvirt-fedora-31/main.yml
@@ -18,10 +18,12 @@ projects:
- virt-manager
- virt-viewer
+os:
+ name: 'Fedora'
+ version: '31'
+
package_format: 'rpm'
package_manager: 'dnf'
-os_name: 'Fedora'
-os_version: '31'
bash: /bin/bash
cc: /usr/bin/gcc
diff --git a/guests/host_vars/libvirt-fedora-rawhide/main.yml
b/guests/host_vars/libvirt-fedora-rawhide/main.yml
index 374cb4c..b11e37c 100644
--- a/guests/host_vars/libvirt-fedora-rawhide/main.yml
+++ b/guests/host_vars/libvirt-fedora-rawhide/main.yml
@@ -18,10 +18,12 @@ projects:
- virt-manager
- virt-viewer
+os:
+ name: 'Fedora'
+ version: 'Rawhide'
+
package_format: 'rpm'
package_manager: 'dnf'
-os_name: 'Fedora'
-os_version: 'Rawhide'
bash: /bin/bash
cc: /usr/bin/gcc
diff --git a/guests/host_vars/libvirt-freebsd-11/main.yml
b/guests/host_vars/libvirt-freebsd-11/main.yml
index c289221..b01c62b 100644
--- a/guests/host_vars/libvirt-freebsd-11/main.yml
+++ b/guests/host_vars/libvirt-freebsd-11/main.yml
@@ -16,10 +16,12 @@ projects:
- virt-manager
- virt-viewer
+os:
+ name: 'FreeBSD'
+ version: '11'
+
package_format: 'pkg'
package_manager: 'pkg'
-os_name: 'FreeBSD'
-os_version: '11'
bash: /usr/local/bin/bash
cc: /usr/bin/clang
diff --git a/guests/host_vars/libvirt-freebsd-12/main.yml
b/guests/host_vars/libvirt-freebsd-12/main.yml
index 3bc3cc6..5da1446 100644
--- a/guests/host_vars/libvirt-freebsd-12/main.yml
+++ b/guests/host_vars/libvirt-freebsd-12/main.yml
@@ -16,10 +16,12 @@ projects:
- virt-manager
- virt-viewer
+os:
+ name: 'FreeBSD'
+ version: '12'
+
package_format: 'pkg'
package_manager: 'pkg'
-os_name: 'FreeBSD'
-os_version: '12'
bash: /usr/local/bin/bash
cc: /usr/bin/clang
diff --git a/guests/host_vars/libvirt-freebsd-current/main.yml
b/guests/host_vars/libvirt-freebsd-current/main.yml
index 02297e0..03e3615 100644
--- a/guests/host_vars/libvirt-freebsd-current/main.yml
+++ b/guests/host_vars/libvirt-freebsd-current/main.yml
@@ -16,10 +16,12 @@ projects:
- virt-manager
- virt-viewer
+os:
+ name: 'FreeBSD'
+ version: 'Current'
+
package_format: 'pkg'
package_manager: 'pkg'
-os_name: 'FreeBSD'
-os_version: 'Current'
bash: /usr/local/bin/bash
cc: /usr/bin/clang
diff --git a/guests/host_vars/libvirt-opensuse-151/main.yml
b/guests/host_vars/libvirt-opensuse-151/main.yml
index 656de36..4050817 100644
--- a/guests/host_vars/libvirt-opensuse-151/main.yml
+++ b/guests/host_vars/libvirt-opensuse-151/main.yml
@@ -16,10 +16,12 @@ projects:
- virt-manager
- virt-viewer
+os:
+ name: 'OpenSUSE'
+ version: '151'
+
package_format: 'rpm'
package_manager: 'zypper'
-os_name: 'OpenSUSE'
-os_version: '151'
bash: /bin/bash
cc: /usr/bin/gcc
diff --git a/guests/host_vars/libvirt-ubuntu-1604/main.yml
b/guests/host_vars/libvirt-ubuntu-1604/main.yml
index 476d7ed..1e7ab72 100644
--- a/guests/host_vars/libvirt-ubuntu-1604/main.yml
+++ b/guests/host_vars/libvirt-ubuntu-1604/main.yml
@@ -16,10 +16,12 @@ projects:
- osinfo-db-tools
- virt-viewer
+os:
+ name: 'Ubuntu'
+ version: '1604'
+
package_format: 'deb'
package_manager: 'apt-get'
-os_name: 'Ubuntu'
-os_version: '1604'
bash: /bin/bash
cc: /usr/bin/gcc
diff --git a/guests/host_vars/libvirt-ubuntu-1804/main.yml
b/guests/host_vars/libvirt-ubuntu-1804/main.yml
index 5a1ffcf..73e4842 100644
--- a/guests/host_vars/libvirt-ubuntu-1804/main.yml
+++ b/guests/host_vars/libvirt-ubuntu-1804/main.yml
@@ -17,10 +17,12 @@ projects:
- virt-manager
- virt-viewer
+os:
+ name: 'Ubuntu'
+ version: '1804'
+
package_format: 'deb'
package_manager: 'apt-get'
-os_name: 'Ubuntu'
-os_version: '1804'
bash: /bin/bash
cc: /usr/bin/gcc
diff --git a/guests/lcitool b/guests/lcitool
index f4565bc..0a8ad49 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -582,11 +582,11 @@ class Application:
# Different operating systems require different configuration
# files for unattended installation to work, but some operating
# systems simply don't support unattended installation at all
- if facts["os_name"] in ["Debian", "Ubuntu"]:
+ if facts["os"]["name"] in ["Debian",
"Ubuntu"]:
install_config = "preseed.cfg"
- elif facts["os_name"] in ["CentOS", "Fedora"]:
+ elif facts["os"]["name"] in ["CentOS",
"Fedora"]:
install_config = "kickstart.cfg"
- elif facts["os_name"] == "OpenSUSE":
+ elif facts["os"]["name"] == "OpenSUSE":
install_config = "autoinst.xml"
else:
raise Exception(
@@ -707,9 +707,6 @@ class Application:
def _dockerfile_build_varmap_deb(self, facts, mappings, pip_mappings, projects,
cross_arch):
package_format = facts["package_format"]
package_manager = facts["package_manager"]
- os_name = facts["os_name"]
- os_version = facts["os_version"]
- os_full = os_name + os_version
pkgs = {}
cross_pkgs = {}
@@ -717,8 +714,8 @@ class Application:
base_keys = [
"default",
package_format,
- os_name,
- os_full,
+ facts["os"]["name"],
+ facts["os"]["name"] +
facts["os"]["version"],
]
cross_keys = []
if cross_arch:
@@ -780,9 +777,6 @@ class Application:
def _dockerfile_build_varmap_rpm(self, facts, mappings, pip_mappings, projects,
cross_arch):
package_format = facts["package_format"]
package_manager = facts["package_manager"]
- os_name = facts["os_name"]
- os_version = facts["os_version"]
- os_full = os_name + os_version
pkgs = {}
cross_pkgs = {}
@@ -790,8 +784,8 @@ class Application:
keys = [
"default",
package_format,
- os_name,
- os_full,
+ facts["os"]["name"],
+ facts["os"]["name"] +
facts["os"]["version"],
]
# We need to add the base project manually here: the standard
@@ -846,8 +840,6 @@ class Application:
def _dockerfile_format(self, facts, cross_arch, varmap):
package_format = facts["package_format"]
package_manager = facts["package_manager"]
- os_name = facts["os_name"]
- os_version = facts["os_version"]
print("FROM {}".format(facts["docker_base"]))
@@ -867,15 +859,15 @@ class Application:
elif package_format == "rpm":
# Rawhide needs this because the keys used to sign packages are
# cycled from time to time
- if os_name == "Fedora" and os_version == "Rawhide":
+ if facts["os"]["name"] == "Fedora" and
facts["os"]["version"] == "Rawhide":
commands.extend([
"{package_manager} update -y --nogpgcheck fedora-gpg-keys"
])
- if os_name == "CentOS":
+ if facts["os"]["name"] == "CentOS":
# Starting with CentOS 8, most -devel packages are shipped in
# the PowerTools repository, which is not enabled by default
- if os_version != "7":
+ if facts["os"]["version"] != "7":
commands.extend([
"{package_manager} install
'dnf-command(config-manager)' -y",
"{package_manager} config-manager --set-enabled PowerTools
-y",
@@ -883,7 +875,7 @@ class Application:
# VZ development packages are only available for CentOS/RHEL-7
# right now and need a 3rd party repository enabled
- if os_version == "7":
+ if facts["os"]["version"] == "7":
repo = self._get_openvz_repo()
varmap["vzrepo"] =
"\\n\\\n".join(repo.split("\n"))
key = self._get_openvz_key()
@@ -908,7 +900,7 @@ class Application:
# openSUSE doesn't seem to have a convenient way to remove all
# unnecessary packages, but CentOS and Fedora do
- if os_name == "OpenSUSE":
+ if facts["os"]["name"] == "OpenSUSE":
commands.extend([
"{package_manager} clean --all",
])
@@ -995,28 +987,27 @@ class Application:
facts = self._inventory.get_facts(host)
package_format = facts["package_format"]
package_manager = facts["package_manager"]
- os_name = facts["os_name"]
- os_version = facts["os_version"]
- os_full = os_name + os_version
cross_arch = args.cross_arch
if package_format not in ["deb", "rpm"]:
raise Exception("Host {} doesn't support
Dockerfiles".format(host))
if cross_arch:
- if os_name not in ["Debian", "Fedora"]:
- raise Exception("Cannot cross compile on {}".format(os_name))
- if os_name == "Debian" and
cross_arch.startswith("mingw"):
+ if facts["os"]["name"] not in ["Debian",
"Fedora"]:
+ raise Exception("Cannot cross compile on {}".format(
+ facts["os"]["name"],
+ ))
+ if facts["os"]["name"] == "Debian" and
cross_arch.startswith("mingw"):
raise Exception(
"Cannot cross compile for {} on {}".format(
cross_arch,
- os_name,
+ facts["os"]["name"],
)
)
- if os_name == "Fedora" and not
cross_arch.startswith("mingw"):
+ if facts["os"]["name"] == "Fedora" and not
cross_arch.startswith("mingw"):
raise Exception(
"Cannot cross compile for {} on {}".format(
cross_arch,
- os_name,
+ facts["os"]["name"],
)
)
if cross_arch == self._native_arch:
diff --git a/guests/playbooks/update/tasks/base.yml
b/guests/playbooks/update/tasks/base.yml
index 97f365e..e962c56 100644
--- a/guests/playbooks/update/tasks/base.yml
+++ b/guests/playbooks/update/tasks/base.yml
@@ -6,23 +6,23 @@
owner: root
group: root
when:
- - os_name == 'Fedora'
- - os_version == 'Rawhide'
+ - os.name == 'Fedora'
+ - os.version == 'Rawhide'
- name: Enable PowerTools repository
command: '{{ package_manager }} config-manager --set-enabled PowerTools -y'
args:
warn: no
when:
- - os_name == 'CentOS'
- - os_version == '8'
+ - os.name == 'CentOS'
+ - os.version == '8'
- name: Enable EPEL repository
package:
name: epel-release
state: latest
when:
- - os_name == 'CentOS'
+ - os.name == 'CentOS'
- name: Create OpenVZ key
template:
@@ -31,16 +31,16 @@
owner: root
group: root
when:
- - os_name == 'CentOS'
- - os_version == '7'
+ - os.name == 'CentOS'
+ - os.version == '7'
- name: Import OpenVZ key
command: 'rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-OpenVZ'
args:
warn: no
when:
- - os_name == 'CentOS'
- - os_version == '7'
+ - os.name == 'CentOS'
+ - os.version == '7'
- name: Enable OpenVZ repository
template:
@@ -49,8 +49,8 @@
owner: root
group: root
when:
- - os_name == 'CentOS'
- - os_version == '7'
+ - os.name == 'CentOS'
+ - os.version == '7'
- name: Update installed packages
package:
@@ -58,8 +58,8 @@
state: latest
when:
- package_format == 'rpm'
- - not ( os_name == 'Fedora' and
- os_version == 'Rawhide' )
+ - not ( os.name == 'Fedora' and
+ os.version == 'Rawhide' )
- name: Update installed packages
package:
@@ -67,24 +67,24 @@
state: latest
disable_gpg_check: yes
when:
- - os_name == 'Fedora'
- - os_version == 'Rawhide'
+ - os.name == 'Fedora'
+ - os.version == 'Rawhide'
- name: Update installed packages
command: '{{ package_manager }} update --refresh --exclude "kernel*"
-y'
args:
warn: no
when:
- - os_name == 'Fedora'
- - os_version == 'Rawhide'
+ - os.name == 'Fedora'
+ - os.version == 'Rawhide'
- name: Update installed packages
command: '{{ package_manager }} update --disablerepo="*"
--enablerepo=fedora-rawhide-kernel-nodebug "kernel*" -y'
args:
warn: no
when:
- - os_name == 'Fedora'
- - os_version == 'Rawhide'
+ - os.name == 'Fedora'
+ - os.version == 'Rawhide'
- name: Update installed packages
apt:
@@ -105,7 +105,7 @@
args:
warn: no
when:
- - os_name == 'Fedora'
+ - os.name == 'Fedora'
- name: Clean up packages after update
shell: '{{ package_manager }} clean packages -y && {{ package_manager }}
autoremove -y'
@@ -113,14 +113,14 @@
warn: no
when:
- package_format == 'rpm'
- - os_name != 'OpenSUSE'
+ - os.name != 'OpenSUSE'
- name: Clean up packages after update
shell: '{{ package_manager }} clean'
args:
warn: no
when:
- - os_name == 'OpenSUSE'
+ - os.name == 'OpenSUSE'
- name: Clean up packages after update
apt:
diff --git a/guests/playbooks/update/tasks/bootloader.yml
b/guests/playbooks/update/tasks/bootloader.yml
index 3de8c0d..eeaebe6 100644
--- a/guests/playbooks/update/tasks/bootloader.yml
+++ b/guests/playbooks/update/tasks/bootloader.yml
@@ -48,4 +48,4 @@
- { key: 'console', value: 'comconsole' }
- { key: 'autoboot_delay', value: '1' }
when:
- - os_name == 'FreeBSD'
+ - os.name == 'FreeBSD'
diff --git a/guests/playbooks/update/tasks/gitlab.yml
b/guests/playbooks/update/tasks/gitlab.yml
index 7691442..f07279c 100644
--- a/guests/playbooks/update/tasks/gitlab.yml
+++ b/guests/playbooks/update/tasks/gitlab.yml
@@ -14,7 +14,7 @@
force: yes
- name: Register the gitlab-runner agent
- shell: 'gitlab-runner register --non-interactive --config "{{
gitlab_runner_config_dir }}/config.toml" --registration-token "{{
gitlab_runner_secret }}" --url "{{ gitlab_url }}" --executor shell
--tag-list "{{ os_name|lower }}-{{ os_version }}"'
+ shell: 'gitlab-runner register --non-interactive --config "{{
gitlab_runner_config_dir }}/config.toml" --registration-token "{{
gitlab_runner_secret }}" --url "{{ gitlab_url }}" --executor shell
--tag-list "{{ os.name|lower }}-{{ os.version }}"'
args:
creates: '{{ gitlab_runner_config_dir }}/config.toml'
diff --git a/guests/playbooks/update/tasks/kludges.yml
b/guests/playbooks/update/tasks/kludges.yml
index 8af36ab..96fe1a5 100644
--- a/guests/playbooks/update/tasks/kludges.yml
+++ b/guests/playbooks/update/tasks/kludges.yml
@@ -11,7 +11,7 @@
owner: root
group: wheel
when:
- - os_name == 'FreeBSD'
+ - os.name == 'FreeBSD'
- flavor == "jenkins"
# FreeBSD compiles bash without defining SSH_SOURCE_BASHRC, which means
@@ -24,7 +24,7 @@
replace: '\1:setenv=BASH_ENV=~/.bashrc,\3:\\'
register: loginconf
when:
- - os_name == 'FreeBSD'
+ - os.name == 'FreeBSD'
- name: Enable ~/.bashrc
command: cap_mkdb /etc/login.conf
@@ -41,7 +41,7 @@
path: /usr/local/bin/intltool-update
register: intltoolupdate
when:
- - os_name == 'FreeBSD'
+ - os.name == 'FreeBSD'
- name: Fix intltool-update
replace:
@@ -49,5 +49,5 @@
regexp: '^(.*) !~ /\\\$\{\?\$2\}\?/;$'
replace: '\1 !~ /\\$\\{?$2}?/;'
when:
- - os_name == 'FreeBSD'
+ - os.name == 'FreeBSD'
- intltoolupdate.stat.exists
diff --git a/guests/playbooks/update/tasks/packages.yml
b/guests/playbooks/update/tasks/packages.yml
index 4e7d5f6..4517a86 100644
--- a/guests/playbooks/update/tasks/packages.yml
+++ b/guests/playbooks/update/tasks/packages.yml
@@ -38,19 +38,19 @@
- name: '{{ project }}: Look up mappings (OS name)'
set_fact:
- resolved: '{{ resolved|combine({ item: mappings[item][os_name] }) }}'
+ resolved: '{{ resolved|combine({ item: mappings[item][os.name] }) }}'
with_items:
'{{ packages }}'
when:
- - mappings[item][os_name] is defined
+ - mappings[item][os.name] is defined
- name: '{{ project }}: Look up mappings (OS version)'
set_fact:
- resolved: '{{ resolved|combine({ item: mappings[item][os_name + os_version] })
}}'
+ resolved: '{{ resolved|combine({ item: mappings[item][os.name + os.version] })
}}'
with_items:
'{{ packages }}'
when:
- - mappings[item][os_name + os_version] is defined
+ - mappings[item][os.name + os.version] is defined
- name: '{{ project }}: Look up mappings (arch with default)'
set_fact:
@@ -70,19 +70,19 @@
- name: '{{ project }}: Look up mappings (arch with OS name)'
set_fact:
- resolved: '{{ resolved|combine({ item: mappings[item]["x86_64" +
"-" + os_name] }) }}'
+ resolved: '{{ resolved|combine({ item: mappings[item]["x86_64" +
"-" + os.name] }) }}'
with_items:
'{{ packages }}'
when:
- - mappings[item]["x86_64" + "-" + os_name] is defined
+ - mappings[item]["x86_64" + "-" + os.name] is defined
- name: '{{ project }}: Look up mappings (arch with OS version)'
set_fact:
- resolved: '{{ resolved|combine({ item: mappings[item]["x86_64" +
"-" + os_name + os_version] }) }}'
+ resolved: '{{ resolved|combine({ item: mappings[item]["x86_64" +
"-" + os.name + os.version] }) }}'
with_items:
'{{ packages }}'
when:
- - mappings[item]["x86_64" + "-" + os_name + os_version] is
defined
+ - mappings[item]["x86_64" + "-" + os.name + os.version] is
defined
- set_fact:
flattened: []
--
2.25.4