tripleo-ansible/tripleo_ansible/ansible_plugins/tests/molecule/tripleo_dnf_stream/playbook.yml

141 lines
5.6 KiB
YAML

---
- name: Converge
hosts: all
become: true
tasks:
- name: List available modules at test start for debugging purposes
command: dnf module list
register: module_list
- debug:
msg: "{{ module_list.stdout_lines }}"
- debug:
msg: |
"================================================================
PREPARE: enable maven:3.5
================================================================"
- name: Make sure the module is removed before starting
command: dnf module -C -y remove maven:3.5
- name: Disable the module
command: dnf module -C -y reset maven:3.5
- debug:
msg: |
"================================================================
START: enable maven:3.5
================================================================"
- name: Enable maven:3.5 module
tripleo_dnf_stream:
name: "maven:3.5"
state: enabled
- debug:
msg: |
"================================================================
VERIFY: enable maven:3.5
================================================================"
- name: Ensure the module got enabled
shell: "set -o pipefail && dnf module -C -y list --enabled | grep 'maven\\s*3.5'"
failed_when: false
register: check_module
- name: Fail if module not found enabled
fail:
msg: Module maven:3.5 not found
when: check_module.rc != 0
- debug:
msg: |
"================================================================
PREPARE: change php:7.2 to php:7.3
================================================================"
- name: Make sure the module is enabled before starting
command: dnf module -C -y reset php
- name: Enable the module nginx (php has dependencies on nginx) and php
command: "dnf module -y install {{ item }}"
loop:
- "nginx"
- "php:7.2"
- debug:
msg: |
"================================================================
START: change php:7.2 to php:7.3
================================================================"
- name: Enable php:7.3 module
tripleo_dnf_stream:
name: "php:7.3"
state: enabled
- debug:
msg: |
"================================================================
VERIFY: change php:7.2 to php:7.3
================================================================"
- name: Ensure the module got enabled
shell: "set -o pipefail && dnf module -C -y list --enabled | grep 'php\\s*7.3'"
failed_when: false
register: check_module
- name: Fail if module not found enabled
fail:
msg: Module php:7.3 not found
when: check_module.rc != 0
- debug:
msg: |
"================================================================
PREPARE: enable and disable multiple streams
================================================================"
- name: Make sure the module is disabled before starting
command: "dnf module -C -y remove nodejs:12 javapackages-runtime:201801"
- name: Disable the module
command: "dnf module -C -y reset nodejs javapackages-runtime"
- debug:
msg: |
"================================================================
START 1: enable multiple streams
================================================================"
- name: Enable nodejs:12 and javapackages-runtime:201801 module
tripleo_dnf_stream:
name:
- "nodejs:12"
- "javapackages-runtime:201801"
state: enabled
- debug:
msg: |
"================================================================
VERIFY 1: enable multiple streams
================================================================"
- name: Ensure the module got enabled
shell: "set -o pipefail && dnf module -C -y list --enabled | grep '{{ item.split(\":\")[0] }}\\s*{{ item.split(\":\")[1] }}'"
failed_when: false
register: check_module
loop:
- "nodejs:12"
- "javapackages-runtime:201801"
- name: Fail if module not found enabled
fail:
msg: "Module {{ item.item }} not found"
when: item.rc != 0
loop: "{{ check_module.results }}"
- debug:
msg: |
"================================================================
START 2: disable multiple streams
================================================================"
- name: Disable all enabled modules
tripleo_dnf_stream:
name:
- "nodejs:12"
- "javapackages-runtime:201801"
state: disabled
- debug:
msg: |
"================================================================
VERIFY 2: disable multiple streams
================================================================"
- name: Ensure all modules got disabled
shell: "set -o pipefail && dnf module -C -y list --enabled | grep '{{ item.split(\":\")[0] }}\\s*{{ item.split(\":\")[1] }}'"
failed_when: false
register: check_module
loop:
- "nodejs:12"
- "javapackages-runtime:201801"
- name: Fail if module found enabled
fail:
msg: "Module {{ item.item }} found enabled when it shouldn't"
when: item.rc == 0
loop: "{{ check_module.results }}"