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
patchback[bot] 7ef25be10c
Add integration tests for snap (#2907) (#2909)
* Add integration tests for snap

* Also test on fedora and remove snapd if it was not installed

* disable test for now

(cherry picked from commit a97d82be88)

Co-authored-by: Amin Vakil <info@aminvakil.com>
2021-06-30 15:22:18 +02:00

72 lines
1.9 KiB
YAML

---
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- name: install snapd
apt:
name: snapd
state: present
register: snapd_install_ubuntu
when: ansible_distribution == 'Ubuntu'
- name: install snapd
dnf:
name: snapd
state: present
register: snapd_install_fedora
when: ansible_distribution == 'Fedora'
- block:
- name: install package
community.general.snap:
name: hello-world
state: present
register: install
- 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_again is not changed
- name: check package has been installed correctly
command: hello-world
- name: remove package
community.general.snap:
name: hello-world
state: absent
register: remove
- 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_again is not changed
when: ansible_distribution in ['Ubuntu','Fedora']
- name: Remove snapd in case it was not installed
apt:
name: snapd
state: absent
when: snapd_install_ubuntu is changed and ansible_distribution == 'Ubuntu'
- name: Remove snapd in case it was not installed
dnf:
name: snapd
state: absent
when: snapd_install_fedora is changed and ansible_distribution == 'Fedora'