test: fix syntax for ansible-lint

This commit is contained in:
Adrien Waksberg 2023-07-26 16:19:27 +02:00
parent aa1958992b
commit 3a46cdbb2c
3 changed files with 32 additions and 30 deletions

View file

@ -1,45 +1,45 @@
---
- name: install certbot package
- name: Install certbot package
ansible.builtin.apt:
name:
- certbot
- cron
default_release: '{{ certbot_distribution|default(ansible_distribution_release) }}'
default_release: "{{ certbot_distribution | default(ansible_distribution_release) }}"
state: present
tags: certbot
- name: create webroot path directory
- name: Create webroot path directory
ansible.builtin.file:
path: '{{ certbot_path }}'
path: "{{ certbot_path }}"
owner: root
group: root
mode: 0755
state: directory
tags: certbot
- name: install hooks script
- name: Install hooks script
ansible.builtin.copy:
content: '{{ item.value|default("#!/bin/bash") }}'
dest: '/etc/letsencrypt/hook-{{ item.key }}'
content: "{{ item.value | default('#!/bin/bash') }}"
dest: "/etc/letsencrypt/hook-{{ item.key }}"
owner: root
group: root
mode: 0700
loop: '{{ certbot_domains|dict2items }}'
loop: "{{ certbot_domains | dict2items }}"
loop_control:
label: '{{ item.key }}'
label: "{{ item.key }}"
tags: certbot
- name: remove old cerbot renew cron
- name: Remove old cerbot renew cron
ansible.builtin.file:
path: /etc/cron.d/certbot
state: absent
tags: certbot
- name: add certbot renew cron
- name: Add certbot renew cron
ansible.builtin.cron:
name: certbot-renew
user: root
hour: '*/12'
minute: '0'
job: perl -e 'sleep int(rand(3600))' && certbot -q renew
hour: "*/12"
minute: "0"
job: "perl -e 'sleep int(rand(3600))' && certbot -q renew"
tags: certbot

View file

@ -1,40 +1,40 @@
---
- name: check if certificate exist
- name: Check if certificate exist
ansible.builtin.stat:
path: '/etc/letsencrypt/live/{{ item.key }}'
loop: '{{ certbot_domains|dict2items }}'
path: "/etc/letsencrypt/live/{{ item.key }}"
loop: "{{ certbot_domains | dict2items }}"
loop_control:
label: '{{ item.key }}'
label: "{{ item.key }}"
register: st
tags: certbot
- name: check if a webservice is started
- name: Check if a webservice is started
ansible.builtin.wait_for:
port: '{{ certbot_port }}'
port: "{{ certbot_port }}"
state: started
timeout: 2
ignore_errors: true
register: web
tags: certbot
- name: create a new certificate
- name: Create a new certificate # noqa no-changed-when
ansible.builtin.command: >
certbot certonly -n --agree-tos -d {{ item.item.key }} -m {{ certbot_mail }}
--webroot --webroot-path {{ certbot_path }} --rsa-key-size {{ certbot_key_size }}
--deploy-hook /etc/letsencrypt/hook-{{ item.item.key }}
loop: '{{ st.results }}'
loop: "{{ st.results }}"
loop_control:
label: '{{ item.item.key }}'
when: (certbot_role == 'master' or item.item.key == ansible_fqdn) and not item.stat.exists and not web.failed
label: "{{ item.item.key }}"
when: (certbot_role == "master" or item.item.key == ansible_fqdn) and not item.stat.exists and not web.failed
tags: certbot
- name: create a new certificate (standalone)
- name: Create a new certificate (standalone) # noqa no-changed-when
ansible.builtin.command: >
certbot certonly -n --agree-tos -d {{ item.item.key }} -m {{ certbot_mail }}
--standalone --rsa-key-size {{ certbot_key_size }} --deploy-hook /etc/letsencrypt/hook-{{ item.item.key }}
--http-01-port {{ certbot_port }}
loop: '{{ st.results }}'
loop: "{{ st.results }}"
loop_control:
label: '{{ item.item.key }}'
when: (certbot_role == 'master' or item.item.key == ansible_fqdn) and not item.stat.exists and web.failed
label: "{{ item.item.key }}"
when: (certbot_role == "master" or item.item.key == ansible_fqdn) and not item.stat.exists and web.failed
tags: certbot

View file

@ -1,6 +1,8 @@
---
- import_tasks: base.yml
- name: Import base
ansible.builtin.import_tasks: base.yml
tags: certbot
- import_tasks: certificates.yml
- name: Import certificates
ansible.builtin.import_tasks: certificates.yml
tags: certbot