2021-03-25 09:44:44 +01:00
|
|
|
---
|
2023-02-17 12:17:12 +01:00
|
|
|
- name: "Bring up Docker containers"
|
|
|
|
hosts: "localhost"
|
2021-03-25 09:44:44 +01:00
|
|
|
gather_facts: false
|
|
|
|
vars:
|
|
|
|
inventory:
|
2023-02-17 12:17:12 +01:00
|
|
|
- name: "ubuntu_latest"
|
2021-03-25 09:44:44 +01:00
|
|
|
image: "ubuntu:latest"
|
2023-02-17 12:17:12 +01:00
|
|
|
- name: "ubuntu_bionic"
|
2021-03-25 09:44:44 +01:00
|
|
|
image: "ubuntu:bionic"
|
2023-02-17 12:17:12 +01:00
|
|
|
- name: "ubuntu_xenial"
|
2021-03-25 09:44:44 +01:00
|
|
|
image: "ubuntu:xenial"
|
2023-02-17 12:17:12 +01:00
|
|
|
- name: "ubuntu_trusty"
|
2021-03-25 09:44:44 +01:00
|
|
|
image: "ubuntu:trusty"
|
|
|
|
# 6/2020: Disabled Debian Testing due to missing python packages (python-apt)
|
|
|
|
#- name: debian_testing
|
|
|
|
# image: "debian:testing"
|
2023-02-17 12:17:12 +01:00
|
|
|
- name: "debian_stable"
|
2021-03-25 09:44:44 +01:00
|
|
|
image: "debian:stable"
|
2023-02-17 12:17:12 +01:00
|
|
|
- name: "debian_oldstable"
|
2021-03-25 09:44:44 +01:00
|
|
|
image: "debian:oldstable"
|
|
|
|
roles:
|
2023-02-17 12:17:12 +01:00
|
|
|
- role: "provision_docker"
|
2021-03-25 09:44:44 +01:00
|
|
|
provision_docker_inventory: "{{ inventory }}"
|
|
|
|
provision_docker_privileged: true
|
|
|
|
provision_docker_use_docker_connection: true
|
|
|
|
|
2023-02-17 12:17:12 +01:00
|
|
|
- name: "Test role"
|
|
|
|
hosts: "docker_containers"
|
2021-03-25 09:44:44 +01:00
|
|
|
gather_facts: false
|
|
|
|
pre_tasks:
|
2023-02-17 12:17:12 +01:00
|
|
|
- name: "Provision Python"
|
|
|
|
raw: 'bash -c "test -e /usr/bin/python || (apt-get -y update && apt-get install -y python)"'
|
|
|
|
register: "output"
|
|
|
|
changed_when: "output.stdout"
|
|
|
|
- name: "Gather facts"
|
2021-03-25 09:44:44 +01:00
|
|
|
setup:
|
|
|
|
vars:
|
|
|
|
unattended_autofix_interrupted_dpkg: false
|
|
|
|
unattended_minimal_steps: true
|
|
|
|
unattended_install_on_shutdown: true
|
|
|
|
unattended_automatic_reboot: true
|
|
|
|
unattended_update_days: '{"Sat"}'
|
|
|
|
roles:
|
|
|
|
# Searched for in ../.. (see ansible.cfg)
|
2023-02-17 12:17:12 +01:00
|
|
|
- "ansible-role-unattended-upgrades"
|
2021-03-25 09:44:44 +01:00
|
|
|
tasks:
|
2023-02-17 12:17:12 +01:00
|
|
|
- name: "Idempotency check"
|
2021-03-25 09:44:44 +01:00
|
|
|
include_role:
|
2023-02-17 12:17:12 +01:00
|
|
|
name: "ansible-role-unattended-upgrades"
|
|
|
|
register: "idempotency"
|
|
|
|
- name: "fail when idempotency.changed"
|
2021-03-25 09:44:44 +01:00
|
|
|
fail:
|
2023-02-17 12:17:12 +01:00
|
|
|
msg: "Role failed idempotency check"
|
|
|
|
when: "idempotency.changed"
|
2021-03-25 09:44:44 +01:00
|
|
|
|
2023-02-17 12:17:12 +01:00
|
|
|
- name: "Get apt-config variables"
|
|
|
|
command: "apt-config dump"
|
|
|
|
register: "aptconfig"
|
2021-03-25 09:44:44 +01:00
|
|
|
changed_when: false
|
2023-02-17 12:17:12 +01:00
|
|
|
- name: "Check for registered variables"
|
2021-03-25 09:44:44 +01:00
|
|
|
assert:
|
2023-02-17 12:17:12 +01:00
|
|
|
that: "item in aptconfig.stdout"
|
2021-03-25 09:44:44 +01:00
|
|
|
with_items:
|
|
|
|
- 'APT::Periodic::Unattended-Upgrade "1"'
|
|
|
|
- 'Unattended-Upgrade::AutoFixInterruptedDpkg "false"'
|
|
|
|
- 'Unattended-Upgrade::MinimalSteps "true"'
|
|
|
|
- 'Unattended-Upgrade::InstallOnShutdown "true"'
|
|
|
|
- 'Unattended-Upgrade::Automatic-Reboot "true"'
|
|
|
|
# NOTE: this uses the array syntax, which requires one
|
|
|
|
# top-level record, then one item per line
|
|
|
|
- 'Unattended-Upgrade::Update-Days "";'
|
|
|
|
- 'Unattended-Upgrade::Update-Days:: "Sat";'
|
|
|
|
|
2023-02-17 12:17:12 +01:00
|
|
|
- name: "Dry run unattended-upgrades"
|
|
|
|
command: "/usr/bin/unattended-upgrades --dry-run"
|
|
|
|
changed_when: "idempotency.changed | bool"
|