ansible-role-step-ca/tasks/main.yml

119 lines
2.7 KiB
YAML
Raw Normal View History

2021-05-30 01:00:24 +02:00
---
- name: copy binaries
2021-05-30 01:00:24 +02:00
copy:
src: "{{ item.src }}"
dest: "{{ item.dst }}"
2021-05-30 01:00:24 +02:00
owner: root
group: root
mode: '0755'
2021-05-30 01:00:24 +02:00
backup: yes
with_items:
- { src: "files/step/step_0.15.16/{{ ansible_architecture }}/bin/step", dst: "/bin/step" }
- { src: "files/step-ca/step-ca_0.15.15/{{ ansible_architecture }}/bin/step-ca", dst: "/bin/step-ca" }
2021-05-30 01:00:24 +02:00
- name: create user for step-ca
user:
name: step
state: present
shell: /bin/false
system: yes
createhome: yes
home: /etc/step-ca
- name: generate /etc/step-ca/password.txt
template:
src: password.txt.j2
dest: /etc/step-ca/password.txt
owner: step
group: step
2021-05-30 19:43:31 +02:00
mode: "0770"
2021-05-30 01:00:24 +02:00
- name: link .step to /etc/step-ca
file:
state: link
src: /etc/step-ca
dest: ~/.step
- name: init step-ca
command: step ca init -ssh --name="{{ pki_name }}" --dns {{ ansible_hostname }} --issuer="{{ pki_name }}" --address=:4343 --provisioner="{{ pki_name }}" --password-file=/etc/step-ca/password.txt --provisioner-password-file=/etc/step-ca/password.txt
2021-05-30 01:00:24 +02:00
args:
creates: /etc/step-ca/config
- name: create /etc/step-ca/db
file:
state: directory
path: /etc/step-ca/db
owner: step
group: step
mode: "0770"
- name: set permissions correct
file:
dest: /etc/step-ca
owner: step
group: step
mode: "0770"
recurse: yes
- name: correct paths
replace:
path: "{{ item }}"
regexp: '\/root\/.step'
replace: "\/etc\/step-ca"
with_items:
- /etc/step-ca/config/ca.json
- /etc/step-ca/config/defaults.json
- name: generate /etc/systemd/system/step-ca.service
template:
src: step-ca.service.j2
dest: /etc/systemd/system/step-ca.service
owner: root
group: root
mode: "0644"
notify:
- reload systemd
2021-05-30 19:43:31 +02:00
- name: Flush handlers
meta: flush_handlers
2021-05-30 01:00:24 +02:00
- name: enable step-ca
systemd:
name: step-ca
enabled: yes
2021-05-30 19:43:31 +02:00
masked: no
2021-05-30 21:32:59 +02:00
notify:
restart step-ca
- name: Flush handlers
meta: flush_handlers
2021-05-30 19:43:31 +02:00
- name: check for acme privisioner
lineinfile:
path: /etc/step-ca/config/ca.json
regexp: '.*"type": "ACME",.*'
line: "{{'\t'}}{{'\t'}}{{'\t'}}{{'\t'}}\"type\": \"ACME\","
state: present
check_mode: yes
register: acmepresent
2021-05-30 19:43:31 +02:00
- name: add acme provisioner
command: step ca provisioner add acme --type ACME
when: acmepresent is changed
2021-05-30 19:43:31 +02:00
notify:
- restart step-ca
- name: check for default JWK privisioner
lineinfile:
path: /etc/step-ca/config/ca.json
regexp: '.*"type": "JWK",.*'
line: "{{'\t'}}{{'\t'}}{{'\t'}}{{'\t'}}\"type\": \"JWK\","
state: present
check_mode: yes
register: jwkpresent
2021-05-30 19:43:31 +02:00
- name: remove jwk provisioner
command: step ca provisioner remove "{{ pki_name }}" --type JWK
when: jwkpresent is not changed
2021-05-30 19:43:31 +02:00
notify:
- restart step-ca