forked from RedHatGov/redhatgov.workshops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.yml
46 lines (39 loc) · 1.26 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# file: roles/LetsEncrypt/tasks/main.yml
---
- name: Gather EC2 instance metadata
action: ec2_metadata_facts
register: ec2_facts
when: letsencrypt
- name: Get resource tags from ec2 facts
become: False
local_action: ec2_tag resource={{ec2_facts.ansible_facts.ansible_ec2_instance_id}} region={{ec2_facts.ansible_facts.ansible_ec2_placement_region}} state=list
register: ec2_tags
when: letsencrypt
- name: Install Certbot Repos
become: yes
yum:
name: "{{ item }}"
state: present
with_items:
- yum-utils
when: letsencrypt
- name: Install Certbot
become: yes
yum:
name: "certbot"
state: present
when: letsencrypt
#- debug:
# var: hostvars[inventory_hostname].ec2_tags.tags.Index
# when: letsencrypt
- name: Generate Certs
become: yes
command: certbot certonly --standalone \
--agree-tos \
--non-interactive \
--text \
--rsa-key-size 4096 \
--email {{ letsencrypt_email }} \
--domains "{{ workshop_prefix | lower }}.{{ hostvars[inventory_hostname].ec2_tags.tags.Index }}.{{ domain_name }}"
when: letsencrypt
# New certs located at: /etc/letsencrypt/live/<url>/