Initial
This commit is contained in:
32
README.md
Normal file
32
README.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# Molecule Podman example
|
||||
|
||||
Based on [Redhat example (Blog post)](https://redhatnordicssa.github.io/test-ansible-role-molecule-podman) and [Redhat example (Repo)](https://github.com/RedHatNordicsSA/molecule-podman-blog).
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
dnf install podman git python3
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
pip install molecule molecule-podman
|
||||
git clone $URL_of_this_repo
|
||||
```
|
||||
|
||||
# Setup Podman
|
||||
|
||||
> Only needed if not done before!
|
||||
|
||||
Setup UID and GID translation between container and host.
|
||||
|
||||
```
|
||||
echo "<username>:200000:65536" >> /etc/subuid
|
||||
echo "<groupname>:200000:65536" >> /etc/subgid
|
||||
```
|
||||
|
||||
# Run test
|
||||
|
||||
```
|
||||
molecule test # to run full test suite
|
||||
molecule converge # to run Playbook under test once and w/o destroying the container
|
||||
molecule login # Start and login to container
|
||||
```
|
||||
14
install.yml
Normal file
14
install.yml
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
|
||||
- hosts: all
|
||||
|
||||
tasks:
|
||||
- name: Install nginx
|
||||
ansible.builtin.dnf:
|
||||
name: nginx
|
||||
|
||||
- name: Start nginx
|
||||
ansible.builtin.systemd:
|
||||
name: nginx
|
||||
state: started
|
||||
enabled: true
|
||||
4
molecule/default/converge.yml
Normal file
4
molecule/default/converge.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
|
||||
- name: Import Playbook under test
|
||||
ansible.builtin.import_playbook: ../../install.yml
|
||||
12
molecule/default/molecule.yml
Normal file
12
molecule/default/molecule.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
|
||||
driver:
|
||||
name: podman
|
||||
platforms:
|
||||
- name: instance
|
||||
image: ubi9/ubi-init
|
||||
pre_build_image: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
privileged: true
|
||||
command: "/usr/sbin/init"
|
||||
37
molecule/default/verify.yml
Normal file
37
molecule/default/verify.yml
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
|
||||
- name: Verfiy nginx
|
||||
hosts: all
|
||||
|
||||
tasks:
|
||||
- name: check if vsftpd is installed
|
||||
ansible.builtin.dnf:
|
||||
name: nginx
|
||||
state: present
|
||||
check_mode: yes
|
||||
register: pkg
|
||||
|
||||
- name: fail if package was not installed
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- pkg.changed is false
|
||||
fail_msg: "Package vsftpd was not installed!"
|
||||
success_msg: "Package vsftpd was installed."
|
||||
|
||||
- name: check service is stopped
|
||||
ansible.builtin.systemd:
|
||||
name: nginx
|
||||
enabled: true
|
||||
state: started
|
||||
check_mode: yes
|
||||
register: svc
|
||||
|
||||
- name: fail if service was activated
|
||||
assert:
|
||||
that:
|
||||
- svc.changed is false
|
||||
success_msg: "Service vsftpd was disabled."
|
||||
fail_msg: "Service vsftpd was activated!"
|
||||
|
||||
- name: test result
|
||||
debug: msg="FTP daemon was installed and disabled. Test OK"
|
||||
Reference in New Issue
Block a user