Mark Goddard e47ff6bd82 Use jinja2.pass_context instead of contextfilter
Jinja2 3.0.0 deprecated contextfilter in favour of pass_context. 3.1.0
dropped contextfilter.

Fall back to contextfilter for Jinja2 2.x.

This change also fixes some issues caused by Ansible lint 6.0. Issues
found by the yaml plugin are fixed, while the FQCN for builtin actions
plugin is skipped.

Change-Id: I97b25551eb26da2c9100120bcd646c88fdb33ba6
2022-03-29 12:36:52 +01:00

69 lines
2.3 KiB
YAML

---
- name: Gather os specific variables
include_vars: "{{ item }}"
with_first_found:
- files:
- "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml"
- "{{ ansible_facts.distribution }}.yml"
- "{{ ansible_facts.os_family }}.yml"
skip: true
tags: vars
- name: Ensure package dependencies are installed
package:
name: "{{ vbmcd_packages }}"
state: present
register: result
until: result is success
retries: 3
become: true
# NOTE(priteau): We need a recent pip to install the latest cryptography
# library. See https://github.com/pyca/cryptography/issues/5753
- name: Ensure a recent version of pip is installed
pip:
name: "pip>=19.1.1"
virtualenv: "{{ vbmcd_virtualenv_path or omit }}"
become: "{{ not vbmcd_virtualenv_path }}"
- name: Ensure Python requirements are installed
pip:
name:
- "virtualbmc>=1.4.0{% if ansible_facts.python.version.major == 2 %},<2{% endif %}"
# NOTE(priteau): Ignore PyYAML when installing system-wide to avoid the
# following error: Cannot uninstall 'PyYAML'. It is a distutils installed
# project and thus we cannot accurately determine which files belong to it
# which would lead to only a partial uninstall.
# NOTE(priteau): Use --no-binary to avoid installing libvirt-python from
# wheel. There is a problem with the 7.5.0 wheel resulting in the error:
# The `libvirt` module is not importable. Check the requirements.
extra_args: >-
-c {{ vbmcd_python_upper_constraints_url }}
{% if not vbmcd_virtualenv_path %}--ignore-installed PyYAML{% endif %}
--no-binary libvirt-python
virtualenv: "{{ vbmcd_virtualenv_path or omit }}"
register: result
until: result is success
retries: 3
become: "{{ not vbmcd_virtualenv_path }}"
- name: Ensure Virtual BMC systemd service is configured
template:
src: templates/{{ item }}.j2
dest: /etc/systemd/system/{{ item }}
owner: root
group: root
mode: 0644
become: true
register: service_file
loop:
- "{{ service }}.service"
- name: Ensure Virtual BMC systemd service is started and enabled
systemd:
name: "{{ service }}"
enabled: true
state: started
daemon_reload: "{{ service_file.changed }}"
become: true