baremetal: refactor package installation into a separate role
* Use package module for all distros * Apply Apt TTL on Debian/Ubuntu Change-Id: Ifb0116df8af7e02ef119780a08e8841d2865cf15
This commit is contained in:
parent
abc4ecef25
commit
844903c586
@ -35,28 +35,6 @@ disable_firewall: True
|
||||
git_http_proxy: ""
|
||||
git_https_proxy: ""
|
||||
|
||||
debian_pkg_install:
|
||||
- git
|
||||
- "{% if enable_multipathd|bool %}sg3-utils-udev{% endif %}"
|
||||
|
||||
openeuler_pkg_install:
|
||||
- python3-docker
|
||||
|
||||
redhat_pkg_install:
|
||||
- git
|
||||
- sudo
|
||||
|
||||
ubuntu_pkg_removals:
|
||||
- lxd
|
||||
- lxc
|
||||
- "{% if enable_nova_libvirt_container | bool %}libvirt-bin{% endif %}"
|
||||
- open-iscsi
|
||||
|
||||
redhat_pkg_removals:
|
||||
- "{% if enable_nova_libvirt_container | bool %}libvirt{% endif %}"
|
||||
- "{% if enable_nova_libvirt_container | bool %}libvirt-daemon{% endif %}"
|
||||
- "{% if enable_nova_libvirt_container | bool %}iscsi-initiator-utils{% endif %}"
|
||||
|
||||
node_config_directory: "/etc/kolla"
|
||||
|
||||
# Whether the nova_libvirt container is enabled.
|
||||
|
@ -1,10 +1,4 @@
|
||||
---
|
||||
- name: Update apt cache
|
||||
apt:
|
||||
update_cache: yes
|
||||
become: True
|
||||
when: ansible_facts.os_family == 'Debian'
|
||||
|
||||
# TODO(inc0): Gates don't seem to have ufw executable, check for it instead of ignore errors
|
||||
- block:
|
||||
- name: Set firewall default policy
|
||||
@ -37,52 +31,8 @@
|
||||
- firewalld_check.rc == 0
|
||||
when: disable_firewall | bool
|
||||
|
||||
- name: Install apt packages
|
||||
package:
|
||||
name: "{{ (debian_pkg_install | join(' ')).split() }}"
|
||||
state: present
|
||||
become: True
|
||||
when: ansible_facts.os_family == 'Debian'
|
||||
|
||||
- name: Install deltarpm packages
|
||||
package:
|
||||
name: drpm
|
||||
state: present
|
||||
update_cache: yes
|
||||
become: True
|
||||
when: ansible_facts.os_family == 'RedHat'
|
||||
|
||||
- name: Install RPM packages
|
||||
package:
|
||||
name: "{{ (redhat_pkg_install | join(' ')).split() }}"
|
||||
state: present
|
||||
update_cache: yes
|
||||
become: True
|
||||
when:
|
||||
- ansible_facts.os_family == 'RedHat'
|
||||
- ansible_facts.distribution != 'openEuler'
|
||||
|
||||
- name: Install RPM packages for openEuler
|
||||
package:
|
||||
name: "{{ (openeuler_pkg_install | join(' ')).split() }}"
|
||||
state: present
|
||||
update_cache: yes
|
||||
become: True
|
||||
when: ansible_facts.distribution == 'openEuler'
|
||||
- import_role:
|
||||
name: openstack.kolla.packages
|
||||
|
||||
- import_role:
|
||||
name: openstack.kolla.docker
|
||||
|
||||
- name: Remove packages
|
||||
package:
|
||||
name: "{{ (ubuntu_pkg_removals | join(' ')).split() }}"
|
||||
state: absent
|
||||
become: True
|
||||
when: ansible_facts.os_family == 'Debian'
|
||||
|
||||
- name: Remove packages
|
||||
package:
|
||||
name: "{{ (redhat_pkg_removals | join(' ')).split() }}"
|
||||
state: absent
|
||||
become: True
|
||||
when: ansible_facts.os_family == 'RedHat'
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
# List of RPM/Apt packages to install.
|
||||
# List of RPM/APT packages to install.
|
||||
docker_sdk_packages:
|
||||
- "python3-setuptools"
|
||||
- "python3-pip"
|
||||
@ -11,6 +11,9 @@ docker_sdk_packages:
|
||||
docker_sdk_pip_packages:
|
||||
- "docker>=2.4.2,<5.0.0"
|
||||
|
||||
# APT cache TTL in seconds.
|
||||
apt_cache_valid_time: 3600
|
||||
|
||||
# Version of python used to execute Ansible modules.
|
||||
host_python_version: "{{ ansible_facts.python.version.major }}.{{ ansible_facts.python.version.minor }}"
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
- name: Install packages
|
||||
package:
|
||||
name: "{{ docker_sdk_packages | select | list }}"
|
||||
cache_valid_time: "{{ apt_cache_valid_time if ansible_facts.os_family == 'Debian' else omit }}"
|
||||
update_cache: "{{ True if ansible_facts.os_family == 'Debian' else omit }}"
|
||||
state: present
|
||||
become: true
|
||||
|
||||
|
30
roles/packages/defaults/main.yml
Normal file
30
roles/packages/defaults/main.yml
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
# Apt cache TTL in seconds.
|
||||
apt_cache_valid_time: 3600
|
||||
|
||||
enable_multipathd: false
|
||||
|
||||
# Whether the nova_libvirt container is enabled.
|
||||
enable_nova_libvirt_container: false
|
||||
|
||||
ubuntu_pkg_install:
|
||||
- git
|
||||
- "{% if enable_multipathd|bool %}sg3-utils-udev{% endif %}"
|
||||
|
||||
openeuler_pkg_install:
|
||||
- python3-docker
|
||||
|
||||
redhat_pkg_install:
|
||||
- git
|
||||
- sudo
|
||||
|
||||
ubuntu_pkg_removals:
|
||||
- lxd
|
||||
- lxc
|
||||
- "{% if enable_nova_libvirt_container | bool %}libvirt-bin{% endif %}"
|
||||
- open-iscsi
|
||||
|
||||
redhat_pkg_removals:
|
||||
- "{% if enable_nova_libvirt_container | bool %}libvirt{% endif %}"
|
||||
- "{% if enable_nova_libvirt_container | bool %}libvirt-daemon{% endif %}"
|
||||
- "{% if enable_nova_libvirt_container | bool %}iscsi-initiator-utils{% endif %}"
|
23
roles/packages/tasks/main.yml
Normal file
23
roles/packages/tasks/main.yml
Normal file
@ -0,0 +1,23 @@
|
||||
---
|
||||
- name: Install packages
|
||||
vars:
|
||||
pkg_installs: >-
|
||||
{{ ubuntu_pkg_install if ansible_facts.os_family == 'Debian'
|
||||
else openeuler_pkg_install if ansible_facts.distribution == 'openEuler'
|
||||
else redhat_pkg_install }}
|
||||
package:
|
||||
name: "{{ pkg_installs | select | list }}"
|
||||
cache_valid_time: "{{ apt_cache_valid_time if ansible_facts.os_family == 'Debian' else omit }}"
|
||||
update_cache: "{{ True if ansible_facts.os_family == 'Debian' else omit }}"
|
||||
state: present
|
||||
become: true
|
||||
|
||||
- name: Remove packages
|
||||
vars:
|
||||
pkg_removals: >-
|
||||
{{ ubuntu_pkg_removals if ansible_facts.os_family == 'Debian'
|
||||
else redhat_pkg_removals }}
|
||||
package:
|
||||
name: "{{ pkg_removals | select | list }}"
|
||||
state: absent
|
||||
become: true
|
Loading…
x
Reference in New Issue
Block a user