mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-10 12:40:31 -07:00
* Try some snap fixes.
* Fix logic.
* Try to run tests privileged.
* Prevent failure on rc != 0.
* Fix formatting.
* Revert "Try to run tests privileged."
This reverts commit 77ca91f502
.
* Try to run tests on RHEL instead.
* Make sure that snapd is running.
* Add changelog fragment.
* str -> to_native.
* Make sure that installed binary is actually found.
* Add check mode tests.
* Mention #2835 in changelog fragment.
98 lines
2.7 KiB
YAML
98 lines
2.7 KiB
YAML
---
|
|
####################################################################
|
|
# 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
|