Skip to content

Commit

Permalink
Update role to Leap 15.6 and podman
Browse files Browse the repository at this point in the history
This commit is large, I apoligize for it but there was no clever way to
split this up. It's a long overdue maintenance update.

Update the molecule tasks to use podman instead of docker and update the
test runs to use Leap 15.5 and Leap 15.6.

Also do some cleanup of the tests and required changes to make them work
again.

Also remove Debian bullseye.

Signed-off-by: phoenix <[email protected]>
  • Loading branch information
grisu48 committed Jul 16, 2024
1 parent 1e9acd5 commit 50c33f7
Show file tree
Hide file tree
Showing 20 changed files with 82 additions and 99 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: pip3 install ansible molecule[docker] docker pytest testinfra
python-version: '3.11'
- name: Install requirements
run: sudo apt-get install podman python3-pip
- name: Install molecule
run: "pip3 install ansible-core molecule molecule-plugins[podman] pytest testinfra"

Check warning on line 39 in .github/workflows/CI.yml

View workflow job for this annotation

GitHub Actions / Lint

39:81 [line-length] line too long (91 > 80 characters)

Check warning on line 39 in .github/workflows/CI.yml

View workflow job for this annotation

GitHub Actions / Lint

39:81 [line-length] line too long (91 > 80 characters)
- name: Install ansible collections
run: ansible-galaxy collection install community.general
- name: Run Molecule
run: molecule test
env:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

Configurable ansible role for setting up a nginx webserver on a Linux server. Works with

- openSUSE Leap 15.3
- openSUSE Leap 15.4
- Debian Buster
- openSUSE Leap 15.5
- openSUSE Leap 15.6
- Debian Buster (11)

## Role Variables
--------------
Expand Down
10 changes: 10 additions & 0 deletions files/www/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html>
<head>
<title>nginx</title>
</head>
<body>
<h1>Default page for nginx</h1>
<p>Congratulations! Your nginx role has been successfully installed on this server</p>
</body>
</html>
7 changes: 2 additions & 5 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ galaxy_info:
platforms:
- name: opensuse
versions:
- 15.3
- 15.4
- name: debian
versions:
- bullseye
- 15.5
- 15.6

galaxy_tags:
- nginx
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM docker.io/debian:bullseye
FROM docker.io/debian:bookworm

# Install systemd, and development tools, clear cache and clean system
RUN apt-get update && apt-get install -y systemd systemd-sysv python3 curl && rm -rf /var/cache/* && systemctl mask -- dev-hugepages.mount sys-fs-fuse-connections.mount && rm -f /etc/machine-id /var/lib/dbus/machine-id
Expand Down
7 changes: 7 additions & 0 deletions molecule/default/Containerfile.leap15_5
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM registry.opensuse.org/opensuse/leap:15.5

# Install systemd and development tools, clear cache
RUN zypper in -y systemd systemd-sysvinit python311 curl && rm -rf /var/cache/*

# Start container with systemd
ENTRYPOINT ["/usr/sbin/init"]
7 changes: 7 additions & 0 deletions molecule/default/Containerfile.leap15_6
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM registry.opensuse.org/opensuse/leap:15.6

# Install systemd and development tools, clear cache
RUN zypper in -y systemd systemd-sysvinit firewalld python311 curl && rm -rf /var/cache/*

# Start container with systemd
ENTRYPOINT ["/usr/sbin/init"]
9 changes: 0 additions & 9 deletions molecule/default/Dockerfile.bullseye

This file was deleted.

7 changes: 0 additions & 7 deletions molecule/default/Dockerfile.leap15_4

This file was deleted.

46 changes: 24 additions & 22 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,44 @@
dependency:
name: galaxy
driver:
name: docker
name: podman
platforms:
- name: leap15_4
image: registry.opensuse.org/opensuse/leap:15.4
dockerfile: Dockerfile.leap15_4
- name: leap15_5
image: registry.opensuse.org/opensuse/leap:15.5
dockerfile: Containerfile.leap15_5
command: ${MOLECULE_DOCKER_COMMAND:-"/usr/sbin/init"}
privileged: true
cgroupns: host
systemd: true
tmpfs:
- /run
- /tmp
- name: bullseye
image: docker.io/debian:bullseye
dockerfile: Dockerfile.bullseye
command: ${MOLECULE_DOCKER_COMMAND:-"/sbin/init"}
privileged: true
cgroupns: host
"/tmp": "exec"
"/run": "rw,noexec,nosuid,nodev"
- name: leap15_6
image: registry.opensuse.org/opensuse/leap:15.6
dockerfile: Containerfile.leap15_6
command: ${MOLECULE_DOCKER_COMMAND:-"/usr/sbin/init"}
systemd: true
tmpfs:
- /run
- /tmp
"/tmp": "exec"
"/run": "rw,noexec,nosuid,nodev"
- name: bookworm
image: docker.io/debian:bookworm
dockerfile: Dockerfile.bookworm
dockerfile: Containerfile.bookworm
command: ${MOLECULE_DOCKER_COMMAND:-"/sbin/init"}
privileged: true
cgroupns: host
systemd: true
tmpfs:
- /run
- /tmp
"/tmp": "exec"
"/run": "rw,noexec,nosuid,nodev"
provisioner:
name: ansible
inventory:
host_vars:
leap15_4:
leap15_5:
vhosts_dir: "/etc/nginx/vhosts.d"
deploy_nginx_config: true
ansible_python_interpreter: "/usr/bin/python3.11"
leap15_6:
vhosts_dir: "/etc/nginx/vhosts.d"
deploy_nginx_config: true
ansible_python_interpreter: "/usr/bin/python3.11"
bullseye:
vhosts_dir: "/etc/nginx/sites-enabled"
deploy_nginx_config: false
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/tests/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')

def test_phpinfo(host):
def test_index(host):
cmd = host.run("curl -v http://127.0.0.1/index.html")
print(cmd.stdout)
assert 'HTTP/1.1 200 OK' in cmd.stderr
Expand Down
26 changes: 10 additions & 16 deletions tasks/default-page.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
---
# setup a default page
# setup default page

- name: Ensure default page directory exists
file:
path: /srv/www/default
- name: Ensure default template exists
copy:
src: www/
dest: "{{www_dir}}/default/"
owner: "{{nginx_user}}"
group: "{{nginx_group}}"
mode: 0755
state: directory
tags: ['nginx']
- name: Ensure default page exists
template:
src: index.j2
dest: "{{www_dir}}/default/index.html"
owner: "{{nginx_user}}"
group: "{{nginx_group}}"
mode: 0755
mode: 0644
directory_mode: 0755
force: false
tags: ['nginx']

- name: Ensure default page nginx template exists
template:
src: default-www.j2
dest: "{{vhosts_dir}}/default-www.conf"
src: default.j2
dest: "{{vhosts_dir}}/default.conf"
owner: root
group: root
mode: 0644
Expand Down
5 changes: 4 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@

# Distribution specific vars are ALWAYS needed, so don't forget the tags here
- name: include distribution specific vars
include_vars: "{{ansible_distribution}}_{{ansible_distribution_version}}.yml"
include_vars: "{{ansible_distribution}}.yml"
tags: ['nginx', 'firewall', 'systemd']

- include_tasks: software.yml
tags: ['nginx', 'firewall', 'systemd']
- include_tasks: firewall.yml
when: config_firewall == true
tags: ['firewall']
- include_tasks: default-page.yml
when: setup_default_page == true
tags: ['nginx']
1 change: 1 addition & 0 deletions tasks/software.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
name: "{{ packages }}"
state: present
tags: ['nginx']

- name: Ensure nginx service is enabled
systemd:
name: "{{ nginx_service }}"
Expand Down
2 changes: 1 addition & 1 deletion templates/default-www.j2 → templates/default.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ server {
listen [::]:80;

root /srv/www/default;
index index.php index.html index.htm;
index index.html index.htm;

server_name {{default_page_hostname}};

Expand Down
13 changes: 0 additions & 13 deletions templates/index.j2

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
# vars file for lemp
# vars file for nginx
5 changes: 3 additions & 2 deletions vars/openSUSE Leap_15.4.yml → vars/openSUSE Leap.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
# openSUSE Leap 15.4 specific variables
# openSUSE Leap specific variables

## Software packages

packages: ['nginx']
packages:
- nginx
nginx_service: "nginx"

## OS-Specific directories
Expand Down
14 changes: 0 additions & 14 deletions vars/openSUSE Leap_15.3.yml

This file was deleted.

0 comments on commit 50c33f7

Please sign in to comment.