roles: use longer format for when conditionals

When the condition is an AND we can use this more succinct format.
This commit is contained in:
Alan Orth 2022-09-10 23:12:49 +03:00
parent 677cc9f160
commit 1da0da53ec
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
5 changed files with 31 additions and 9 deletions

View File

@ -5,7 +5,9 @@
notify: restart fail2ban
- name: Configure fail2ban nginx filter
when: "extra_fail2ban_filters is defined and 'nginx' in extra_fail2ban_filters"
when:
- extra_fail2ban_filters is defined
- "'nginx' in extra_fail2ban_filters"
ansible.builtin.template: src=etc/fail2ban/jail.d/nginx.local.j2 dest=/etc/fail2ban/jail.d/nginx.local owner=root mode=0644
notify: restart fail2ban

View File

@ -40,7 +40,9 @@
tags: sysctl
- name: Reconfigure /etc/rc.local
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('19.04', '<=')
when:
- ansible_distribution == 'Ubuntu'
- ansible_distribution_version is version('19.04', '<=')
ansible.builtin.template: src=rc.local_Ubuntu.j2 dest=/etc/rc.local owner=root group=root mode=0755
- name: Set I/O scheduler

View File

@ -44,7 +44,9 @@
ansible.builtin.file:
dest: "{{ letsencrypt_acme_script_temp }}"
state: absent
when: acme_install.rc is defined and acme_install.rc == 0
when:
- acme_install.rc is defined
- acme_install.rc == 0
- name: Set default certificate authority for acme.sh
ansible.builtin.command:

View File

@ -3,12 +3,16 @@
- block:
- name: Install WordPress
ansible.builtin.git: repo=https://github.com/WordPress/WordPress.git dest={{ nginx_root_prefix }}/{{ item.domain_name }}/wordpress version={{ item.wordpress_version }} depth=1 force=true
when: item.has_wordpress is defined and item.has_wordpress
when:
- item.has_wordpress is defined
- item.has_wordpress == true
loop: "{{ nginx_vhosts }}"
- name: Fix WordPress directory permissions
ansible.builtin.file: path={{ nginx_root_prefix }}/{{ item.domain_name }} state=directory owner=nginx group=nginx recurse=true
when: item.has_wordpress is defined and item.has_wordpress
when:
- item.has_wordpress is defined
- item.has_wordpress == true
loop: "{{ nginx_vhosts }}"
tags: wordpress

View File

@ -29,22 +29,34 @@
- name: Configure php-fpm on Ubuntu 18.04
ansible.builtin.include_tasks: Ubuntu_18.04.yml
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('18.04', '==') and install_php
when:
- ansible_distribution == 'Ubuntu'
- ansible_distribution_version is version('18.04', '==')
- install_php == true
tags: php-fpm
- name: Configure php-fpm on Debian 10
ansible.builtin.include_tasks: Debian_10.yml
when: ansible_distribution == 'Debian' and ansible_distribution_version is version('10', '==') and install_php
when:
- ansible_distribution == 'Debian'
- ansible_distribution_version is version('10', '==')
- install_php == true
tags: php-fpm
- name: Configure php-fpm on Ubuntu 20.04
ansible.builtin.include_tasks: Ubuntu_20.04.yml
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '==') and install_php
when:
- ansible_distribution == 'Ubuntu'
- ansible_distribution_version is version('20.04', '==')
- install_php == true
tags: php-fpm
- name: Configure php-fpm on Debian 11
ansible.builtin.include_tasks: Ubuntu_20.04.yml
when: ansible_distribution == 'Debian' and ansible_distribution_version is version('11', '==') and install_php
when:
- ansible_distribution == 'Debian'
- ansible_distribution_version is version('11', '==')
- install_php == true
tags: php-fpm
# vim: set ts=2 sw=2: