Skip to content

Commit

Permalink
Enable docker flag for molecule usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
r-pufky committed Mar 18, 2024
1 parent ab12e09 commit 1e22517
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 41 deletions.
23 changes: 12 additions & 11 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
---

Check failure on line 1 in molecule/default/converge.yml

View workflow job for this annotation

GitHub Actions / build

load-failure[runtimeerror]

Failed to load YAML file: molecule/default/converge.yml

- name: Converge
hosts: all
- name: 'Converge'
hosts: 'all'
environment:
http_proxy: "{{ lookup('env', 'http_proxy') }}"
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
no_proxy: "{{ lookup('env', 'no_proxy') }}"
no_proxy: "{{ lookup('env', 'no_proxy') }}"
remote_user: root
vars:
pihole_disable_warning: true
pihole_docker: true
pre_tasks:
- name: Ubuntu | Install python3
ansible.builtin.raw: test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal)
- name: 'Ubuntu | Install python3'
ansible.builtin.raw: 'test -e /usr/bin/python3 || (apt -y update && apt install -y python3-minimal)'
register: python3
changed_when: "'installed' in python3.stdout"
when: (ansible_distribution == "Ubuntu" and ansible_distribution_major_version | int >= 16)
- name: RedHat | Install python3
ansible.builtin.raw: test -e /usr/bin/python3 || (yum install -y python3)
- name: 'RedHat | Install python3'
ansible.builtin.raw: 'test -e /usr/bin/python3 || (yum install -y python3)''
register: python3
changed_when: "'installed' in python3.stdout"

Check failure on line 22 in molecule/default/converge.yml

View workflow job for this annotation

GitHub Actions / build

22:23 syntax error: expected <block end>, but found '<scalar>' (syntax)
when: (ansible_os_family == "RedHat" and ansible_distribution_major_version | int >= 8)
- name: Gather Facts
- name: 'Gather Facts'
ansible.builtin.setup:
when: (ansible_distribution == "Ubuntu" and ansible_distribution_major_version | int >= 16)
- name: Ubuntu Bionic+, Redhat 8+ | Enforce python3 for ansible
- name: 'Ubuntu Bionic+, Redhat 8+ | Enforce python3 for ansible'
ansible.builtin.set_fact:
ansible_python_interpreter: /usr/bin/python3
ansible_python_interpreter: '/usr/bin/python3'
when: >
(ansible_distribution == "Ubuntu" and ansible_distribution_major_version | int >= 16) or
(ansible_os_family == "RedHat" and ansible_distribution_major_version | int >= 8)
Expand Down
60 changes: 30 additions & 30 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---

- name: Verify
hosts: pihole_group
- name: 'Verify'
hosts: 'pihole_group'
vars:
bin_filepath: /usr/local/bin/pihole
config_filepath: /etc/pihole/pihole-FTL.conf
bin_filepath: '/usr/local/bin/pihole'
config_filepath: '/etc/pihole/pihole-FTL.conf'
ports:
# https://docs.pi-hole.net/main/prerequisites/#ports
- { h: 0.0.0.0, p: 53 }
- { h: localhost, p: 80 }
- { h: localhost, p: 4711 }
url: http://localhost
url: 'http://localhost'
is_container: false
pre_tasks:
- name: Debug | var ansible_virtualization_type
- name: 'Debug | var ansible_virtualization_type'
ansible.builtin.debug:
var: ansible_virtualization_type
- name: Set fact is_container
- name: 'Set fact is_container'
ansible.builtin.set_fact:
is_container: true
when: >
Expand All @@ -25,58 +25,58 @@
or ansible_virtualization_type == "container"
)
)
- name: RedHat | install procps-ng
- name: 'RedHat | install procps-ng'
ansible.builtin.package:
name: procps-ng
state: present
name: 'procps-ng'
state: 'present'
when: ansible_os_family == "RedHat"
- name: Debian | install procps
- name: 'Debian | install procps'
ansible.builtin.package:
name: procps
state: present
name: 'procps'
state: 'present'
when: ansible_os_family == "Debian"
tasks:

- name: Ensure bin file is present
- name: 'Ensure bin file is present'
ansible.builtin.stat:
path: "{{ bin_filepath }}"
register: bin
- name: Validate bin present
- name: 'Validate bin present'
ansible.builtin.assert:
that:
- bin.stat.exists
- bin.stat.size != 0
- bin.stat.mode == '0755'

- name: Check config file
- name: 'Check config file'
ansible.builtin.stat:
path: "{{ config_filepath }}"
register: cfg
- name: Validate configuration file is present
- name: 'Validate configuration file is present'
ansible.builtin.assert:
that: cfg.stat.exists and cfg.stat.size != 0

- name: Ensure process is running
- name: 'Ensure process is running'
ansible.builtin.command: pgrep pihole
register: ps
changed_when: false
failed_when: false
- name: Validate ps output
- name: 'Validate ps output'
ansible.builtin.assert:
that: ps.stdout
when:
- not is_container|bool

- name: Check all processes
- name: 'Check all processes'
ansible.builtin.command: ps aux
changed_when: false
register: psa
- name: Debug | ps aux output
- name: 'Debug | ps aux output'
ansible.builtin.debug:
var: psa
verbosity: 1

- name: Ensure ports are listening
- name: 'Ensure ports are listening'
ansible.builtin.wait_for:
host: "{{ item.h }}"
port: "{{ item.p }}"
Expand All @@ -85,34 +85,34 @@
when:
- not is_container|bool

- name: Fetch localhost endpoint
- name: 'Fetch localhost endpoint'
ansible.builtin.uri:
url: "{{ url }}"
validate_certs: false
return_content: true
register: web
failed_when: false
- name: Validate localhost endpoint
- name: 'Validate localhost endpoint'
ansible.builtin.assert:
that:
- web.status == 200
when:
- not is_container|bool

- name: Ensure pihole version
ansible.builtin.command: pihole version
- name: 'Ensure pihole version'
ansible.builtin.command: 'pihole version'
register: dns1
changed_when: false
failed_when: false

- name: Ensure pihole status
ansible.builtin.command: pihole status
- name: 'Ensure pihole status'
ansible.builtin.command: 'pihole status'
register: dns1
changed_when: false
failed_when: false

- name: Ensure pihole resolution
ansible.builtin.command: nslookup pi.hole
- name: 'Ensure pihole resolution'
ansible.builtin.command: 'nslookup pi.hole'
register: dns1
changed_when: false
failed_when: false

0 comments on commit 1e22517

Please sign in to comment.