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

99 lines
2.7 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
when: has_snap