Merge pull request #2 from justereseau/fix/var_override

Fix: var override
This commit is contained in:
Lucas Maurice 2020-12-08 14:59:30 -05:00 committed by GitHub
commit 8efb868a29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 4 deletions

View File

@ -4,7 +4,7 @@ services: docker
env:
global:
- ROLE_NAME: cloudflare-acme
- ROLE_NAME: cloudflare_acme
matrix:
- MOLECULE_DISTRO: centos7
- MOLECULE_DISTRO: centos8

View File

@ -1,6 +1,6 @@
---
galaxy_info:
role_name: cloudflare-acme
role_name: cloudflare_acme
author: sonic
description: Install and renew SSL certificates with Cloudflare API ; Let's Encrypt ; and acme.sh.
license: MIT

View File

@ -5,4 +5,4 @@
vars:
acme_sh_domains: []
roles:
- role: cloudflare-acme
- role: cloudflare_acme

View File

@ -3,17 +3,20 @@
apt:
update_cache: true
when: ansible_os_family == 'Debian'
changed_when: False
- name: Install dependencies
package:
name:
- git
- wget
state: present
- name: Create git clone path
file:
path: "{{ acme_sh_git_clone_dest | dirname }}"
state: "directory"
mode: "0755"
- name: Git clone acme.sh
git:
@ -77,10 +80,18 @@
- acme_cloudflare_token is defined
- acme_cloudflare_email is defined
loop: "{{ acme_sh_domains }}"
register: issue_result
register: issue_result2
changed_when: issue_result.rc == 0 and "Cert success" in issue_result.stdout and not item.force_renew | default(false)
failed_when: issue_result.rc != 0 and "Domains not changed" not in issue_result.stdout
# Because even with the when, the var is overridden.
- name: Grab the good issue result
set_fact:
issue_result: "{{ issue_result2 }}"
when:
- acme_cloudflare_token is defined
- acme_cloudflare_email is defined
- name: Install acme.sh certificate(s)
command: >-
./acme.sh --install-cert -d {{ item.domain }}