1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/snap/tasks/main.yml

146 lines
4.2 KiB
YAML
Raw Normal View History

---
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- 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"
- block:
- 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
community.general.snap:
name: hello-world
state: present
register: install
- 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
community.general.snap:
name: hello-world
state: present
register: install_again
- name: Assert package has been installed just once
assert:
that:
- install is changed
- install_check is changed
- install_again is not changed
- install_again_check is not changed
- name: Check package has been installed correctly
command: hello-world
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
- name: Remove package
community.general.snap:
name: hello-world
state: absent
register: remove
- 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
community.general.snap:
name: hello-world
state: absent
register: remove_again
- name: Assert package has been removed just once
assert:
that:
- remove is changed
- remove_check is changed
- remove_again is not changed
- remove_again_check is not changed
# - 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
when: has_snap