Skip to content

Commit

Permalink
Fix no-change-when, key-order linting issues.
Browse files Browse the repository at this point in the history
Changed:
* Fixed key-order linter warning to linter preferred order (name,when,block).
* Use specific distribution for handling Ubuntu warnings.
  • Loading branch information
r-pufky committed Mar 18, 2024
1 parent 599b467 commit 94a726d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion tasks/db/db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
loop: '{{ pihole_domain_blocklists }}'
when: not pihole_use_cli and pihole_domain_blocklists|length > 0

- name: 'include | add_clients'
- name: 'DB | include add_clients'
ansible.builtin.include_tasks: add_clients.yml
when: pihole_clients|length > 0
loop: '{{ pihole_clients }}'
Expand Down
7 changes: 3 additions & 4 deletions tasks/deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Manage dependency installation for all platforms and VM's.

- name: 'Dependencies | debian'
when: ansible_distribution == 'Debian'
block:
- name: 'Dependencies | install debian docker packages'
ansible.builtin.apt:
Expand All @@ -18,9 +19,8 @@
name: '{{ pihole_default_packages_debian }}'
state: 'latest'
update_cache: true
when: ansible_distribution == 'Debian'

- name: 'Dependencies | ubuntu'
when: ansible_distribution == 'Ubuntu'
block:
- name: 'Dependencies | install ubuntu docker packages'
ansible.builtin.apt:
Expand All @@ -34,9 +34,9 @@
name: '{{ pihole_default_packages_ubuntu }}'
state: 'latest'
update_cache: true
when: ansible_distribution == 'Ubuntu'

- name: 'Dependencies | redhat'
when: ansible_os_family == 'RedHat'
block:
- name: 'Dependencies | install redhat docker packages'
ansible.builtin.apt:
Expand All @@ -50,4 +50,3 @@
name: '{{ pihole_default_packages_redhat }}'
state: 'latest'
update_cache: true
when: ansible_os_family == 'RedHat'
10 changes: 5 additions & 5 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@
when: not pihole_installed

- name: 'Install | install'
when: not pihole_installed
block:
- name: 'Install | standard install'
- name: 'Install | standard install' # noqa no-changed-when
ansible.builtin.command: '/tmp/pihole-install.sh --unattended'
when: not pihole_docker

- name: 'Install | docker install'
- name: 'Install | docker install' # noqa no-changed-when
ansible.builtin.command: '/tmp/pihole-install.sh --unattended'
environment:
DEBIAN_FRONTEND: noninteractive
when: pihole_docker
when: not pihole_installed

- name: 'Install | set FTL config'
ansible.builtin.template:
Expand All @@ -77,11 +77,11 @@
# Reference:
# * https://medium.com/@AbhijeetKasurde/ansible-generating-random-string-using-password-lookup-plugin-7cd3431a0d0
# * https://discourse.pi-hole.net/t/what-is-setupvars-conf-and-how-do-i-use-it/3533/5
- name: 'Install | set random password (no install password set)'
- name: 'Install | set random password (no install password set)' # noqa no-changed-when
ansible.builtin.command: "pihole -a -p {{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=8') }}"
when: pihole_webpassword|string|length == 0

- name: 'Install | set password'
- name: 'Install | set password' # noqa no-changed-when
ansible.builtin.command: 'pihole -a -p {{ pihole_webpassword }}'
when: pihole_webpassword|string|length > 0
no_log: true # password
4 changes: 2 additions & 2 deletions tasks/os_prep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# * https://github.com/r-pufky/ansible_pihole/issues/10

- name: 'OS prep | config redhat'
when: ansible_os_family == 'RedHat'
block:
- name: 'RedHat Support is Best Effort!'
ansible.builtin.debug:
Expand Down Expand Up @@ -70,9 +71,9 @@
port: '4711/tcp'
permanent: true
state: 'enabled'
when: ansible_os_family == 'RedHat'

- name: 'OS prep | config ubuntu'
when: ansible_distribution == 'Ubuntu'
block:
- name: 'Ubuntu is Unsupported!'
ansible.builtin.debug:
Expand All @@ -86,4 +87,3 @@
echo: false
seconds: "{{ pihole_default_timeout }}"
when: not pihole_disable_warning
when: ansible_os_family == 'Ubuntu'
2 changes: 1 addition & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pihole_default_packages_redhat:
pihole_default_packages_debian_docker:
- 'apt-utils'

pihole_default_package_ubuntu_docker: "{{ pihole_default_packages_debian_docker }}"
pihole_default_packages_ubuntu_docker: "{{ pihole_default_packages_debian_docker }}"

pihole_default_packages_redhat_docker:
- 'selinux-policy'
Expand Down

0 comments on commit 94a726d

Please sign in to comment.