2021-06-30 15:06:56 +02:00
|
|
|
---
|
|
|
|
####################################################################
|
|
|
|
# WARNING: These are designed specifically for Ansible tests #
|
|
|
|
# and should not be used as examples of how to write Ansible roles #
|
|
|
|
####################################################################
|
|
|
|
|
2021-07-01 18:53:48 +02:00
|
|
|
- name: Include distribution specific tasks
|
|
|
|
include_tasks: "{{ lookup('first_found', params) }}"
|
|
|
|
vars:
|
|
|
|
params:
|
|
|
|
files:
|
|
|
|
- "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml"
|
|
|
|
- "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml"
|
|
|
|
- "{{ ansible_facts.distribution }}.yml"
|
|
|
|
- "{{ ansible_facts.os_family }}.yml"
|
|
|
|
- "nothing.yml"
|
|
|
|
paths:
|
|
|
|
- "{{ role_path }}/tasks"
|
2021-06-30 15:06:56 +02:00
|
|
|
|
|
|
|
- block:
|
2021-07-01 18:53:48 +02:00
|
|
|
- name: Make sure package is not installed
|
|
|
|
community.general.snap:
|
|
|
|
name: hello-world
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: Install package (check mode)
|
|
|
|
community.general.snap:
|
|
|
|
name: hello-world
|
|
|
|
state: present
|
|
|
|
register: install_check
|
|
|
|
check_mode: true
|
|
|
|
|
|
|
|
- name: Install package
|
2021-06-30 15:06:56 +02:00
|
|
|
community.general.snap:
|
|
|
|
name: hello-world
|
|
|
|
state: present
|
|
|
|
register: install
|
|
|
|
|
2021-07-01 18:53:48 +02:00
|
|
|
- name: Install package again (check mode)
|
|
|
|
community.general.snap:
|
|
|
|
name: hello-world
|
|
|
|
state: present
|
|
|
|
register: install_again_check
|
|
|
|
check_mode: true
|
|
|
|
|
|
|
|
- name: Install package again
|
2021-06-30 15:06:56 +02:00
|
|
|
community.general.snap:
|
|
|
|
name: hello-world
|
|
|
|
state: present
|
|
|
|
register: install_again
|
|
|
|
|
|
|
|
- name: Assert package has been installed just once
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- install is changed
|
2021-07-01 18:53:48 +02:00
|
|
|
- install_check is changed
|
2021-06-30 15:06:56 +02:00
|
|
|
- install_again is not changed
|
2021-07-01 18:53:48 +02:00
|
|
|
- install_again_check is not changed
|
2021-06-30 15:06:56 +02:00
|
|
|
|
2021-07-01 18:53:48 +02:00
|
|
|
- name: Check package has been installed correctly
|
2021-06-30 15:06:56 +02:00
|
|
|
command: hello-world
|
2021-07-01 18:53:48 +02:00
|
|
|
environment:
|
|
|
|
PATH: /var/lib/snapd/snap/bin/
|
|
|
|
|
|
|
|
- name: Remove package (check mode)
|
|
|
|
community.general.snap:
|
|
|
|
name: hello-world
|
|
|
|
state: absent
|
|
|
|
register: remove_check
|
|
|
|
check_mode: true
|
2021-06-30 15:06:56 +02:00
|
|
|
|
2021-07-01 18:53:48 +02:00
|
|
|
- name: Remove package
|
2021-06-30 15:06:56 +02:00
|
|
|
community.general.snap:
|
|
|
|
name: hello-world
|
|
|
|
state: absent
|
|
|
|
register: remove
|
|
|
|
|
2021-07-01 18:53:48 +02:00
|
|
|
- name: Remove package again (check mode)
|
|
|
|
community.general.snap:
|
|
|
|
name: hello-world
|
|
|
|
state: absent
|
|
|
|
register: remove_again_check
|
|
|
|
check_mode: true
|
|
|
|
|
|
|
|
- name: Remove package again
|
2021-06-30 15:06:56 +02:00
|
|
|
community.general.snap:
|
|
|
|
name: hello-world
|
|
|
|
state: absent
|
|
|
|
register: remove_again
|
|
|
|
|
|
|
|
- name: Assert package has been removed just once
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- remove is changed
|
2021-07-01 18:53:48 +02:00
|
|
|
- remove_check is changed
|
2021-06-30 15:06:56 +02:00
|
|
|
- remove_again is not changed
|
2021-07-01 18:53:48 +02:00
|
|
|
- remove_again_check is not changed
|
2021-07-02 12:52:00 +02:00
|
|
|
|
|
|
|
# - name: Make sure package from classic snap is not installed
|
|
|
|
# community.general.snap:
|
|
|
|
# name: nvim
|
|
|
|
# state: absent
|
|
|
|
#
|
|
|
|
# - name: Install package from classic snap
|
|
|
|
# community.general.snap:
|
|
|
|
# name: nvim
|
|
|
|
# state: present
|
|
|
|
# classic: true
|
|
|
|
# register: classic_install
|
|
|
|
#
|
|
|
|
# # testing classic idempotency
|
|
|
|
# - name: Install package from classic snap again
|
|
|
|
# community.general.snap:
|
|
|
|
# name: nvim
|
|
|
|
# state: present
|
|
|
|
# classic: true
|
|
|
|
# register: classic_install_again
|
|
|
|
#
|
|
|
|
# - name: Assert package has been installed just once
|
|
|
|
# assert:
|
|
|
|
# that:
|
|
|
|
# - classic_install is changed
|
|
|
|
# - classic_install_again is not changed
|
|
|
|
#
|
|
|
|
# # this is just testing if a package which has been installed
|
|
|
|
# # with true classic can be removed without setting classic to true
|
|
|
|
# - name: Remove package from classic snap without setting classic to true
|
|
|
|
# community.general.snap:
|
|
|
|
# name: nvim
|
|
|
|
# state: absent
|
|
|
|
# register: classic_remove_without_true_classic
|
|
|
|
#
|
|
|
|
# - name: Remove package from classic snap with setting classic to true
|
|
|
|
# community.general.snap:
|
|
|
|
# name: nvim
|
|
|
|
# state: absent
|
|
|
|
# classic: true
|
|
|
|
# register: classic_remove_with_true_classic
|
|
|
|
#
|
|
|
|
# - name: Assert package has been removed without setting classic to true
|
|
|
|
# assert:
|
|
|
|
# that:
|
|
|
|
# - classic_remove_without_ture_classic is changed
|
|
|
|
# - classic_remove_with_ture_classic is not changed
|
2021-07-01 18:53:48 +02:00
|
|
|
when: has_snap
|