|
| 1 | +--- |
| 2 | +- name: Validate challenge only if it is created or changed # noqa no-handler |
| 3 | + when: challenge is changed |
| 4 | + block: |
| 5 | + - name: Create challenge file with SAN domain for azure blob storage upload # noqa template-instead-of-copy |
| 6 | + ansible.builtin.copy: |
| 7 | + dest: "acme-challenge.{{ item }}" |
| 8 | + content: "{{ challenge['challenge_data'][item]['http-01']['resource_value'] }}" |
| 9 | + mode: 0640 |
| 10 | + loop: "{{ acme_domain.subject_alt_name }}" |
| 11 | + when: |
| 12 | + - acme_domain.subject_alt_name is defined |
| 13 | + # only runs if the challenge is run the first time, because then there is challenge_data |
| 14 | + - challenge['challenge_data'][item] is defined |
| 15 | + |
| 16 | + - name: Create storage container and upload challenge file to it |
| 17 | + azure.azcollection.azure_rm_storageblob: |
| 18 | + resource_group: "{{ acme_azbs_resource_group }}" |
| 19 | + storage_account_name: "{{ acme_azbs_storage_account_name }}" |
| 20 | + public_access: "blob" |
| 21 | + container: "{{ acme_azbs_container_name }}" |
| 22 | + blob: "{{ challenge['challenge_data'][item]['http-01']['resource'] }}" |
| 23 | + src: "acme-challenge.{{ item }}" |
| 24 | + content_type: 'text/plain' # _type or _encoding have to be set |
| 25 | + subscription_id: "{{ acme_azbs_subscription_id }}" |
| 26 | + client_id: "{{ acme_azbs_client_id }}" |
| 27 | + secret: "{{ acme_azbs_secret }}" |
| 28 | + tenant: "{{ acme_azbs_tenant_id }}" |
| 29 | + loop: "{{ acme_domain.subject_alt_name }}" |
| 30 | + when: |
| 31 | + - acme_domain.subject_alt_name is defined |
| 32 | + # only runs if the challenge is run the first time, because then there is challenge_data |
| 33 | + - challenge['challenge_data'][item] is defined |
| 34 | + |
| 35 | + # validate certficate |
| 36 | + - name: Let the challenge be validated and retrieve the cert and intermediate certificate |
| 37 | + community.crypto.acme_certificate: |
| 38 | + account_key_src: "{{ acme_account_key_path }}" |
| 39 | + account_email: "{{ acme_account_email }}" |
| 40 | + csr: "{{ acme_csr_path }}" |
| 41 | + cert: "{{ acme_cert_path }}" |
| 42 | + fullchain: "{{ acme_fullchain_path }}" |
| 43 | + chain: "{{ acme_intermediate_path }}" |
| 44 | + challenge: http-01 |
| 45 | + force: "{{ acme_force_renewal | default(false) }}" |
| 46 | + acme_directory: "{{ acme_directory }}" |
| 47 | + acme_version: 2 |
| 48 | + terms_agreed: true |
| 49 | + remaining_days: "{{ acme_remaining_days }}" |
| 50 | + data: "{{ challenge }}" |
| 51 | + |
| 52 | + - name: Remove challenge file for SAN domain from azure blob storage container |
| 53 | + azure.azcollection.azure_rm_storageblob: |
| 54 | + resource_group: "{{ acme_azbs_resource_group }}" |
| 55 | + storage_account_name: "{{ acme_azbs_storage_account_name }}" |
| 56 | + container: "{{ acme_azbs_container_name }}" |
| 57 | + blob: "{{ challenge['challenge_data'][item]['http-01']['resource'] }}" |
| 58 | + state: absent |
| 59 | + subscription_id: "{{ acme_azbs_subscription_id }}" |
| 60 | + client_id: "{{ acme_azbs_client_id }}" |
| 61 | + secret: "{{ acme_azbs_secret }}" |
| 62 | + tenant: "{{ acme_azbs_tenant_id }}" |
| 63 | + loop: "{{ acme_domain.subject_alt_name }}" |
| 64 | + when: |
| 65 | + - acme_domain.subject_alt_name is defined |
| 66 | + # only runs if the challenge is run the first time, because then there is challenge_data |
| 67 | + - challenge['challenge_data'][item] is defined |
| 68 | + |
| 69 | + - name: Remove challenge file for SAN domain from fs |
| 70 | + ansible.builtin.file: |
| 71 | + dest: "acme-challenge.{{ item }}" |
| 72 | + state: absent |
| 73 | + loop: "{{ acme_domain.subject_alt_name }}" |
| 74 | + when: |
| 75 | + - acme_domain.subject_alt_name is defined |
| 76 | + # only runs if the challenge is run the first time, because then there is challenge_data |
| 77 | + - challenge['challenge_data'][item] is defined |
0 commit comments