2021-05-30 01:00:24 +02:00
|
|
|
---
|
2021-06-06 18:05:09 +02:00
|
|
|
- name: set package-names for armv7l
|
|
|
|
set_fact:
|
|
|
|
step: step_linux_0.15.16_armv7.tar.gz
|
|
|
|
stepca: step-ca_linux_0.15.15_armv7.tar.gz
|
|
|
|
when: 'ansible_architecture == "armv7l"'
|
|
|
|
|
|
|
|
- name: set package-names for amd64
|
|
|
|
set_fact:
|
|
|
|
step: step_linux_0.15.16_amd64.tar.gz
|
|
|
|
stepca: step-ca_linux_0.15.15_amd64.tar.gz
|
|
|
|
when: ansible_architecture == "amd64"
|
|
|
|
|
|
|
|
- name: stop when facts not set to download Packages
|
|
|
|
meta: end_play
|
|
|
|
when: step is not defined or stepca is not defined
|
|
|
|
|
|
|
|
- name: Download Packages
|
|
|
|
get_url:
|
|
|
|
url: "{{ item }}"
|
|
|
|
dest: /opt/ansiblepackages
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: '0440'
|
|
|
|
with_items:
|
|
|
|
- "https://github.com/smallstep/certificates/releases/download/v0.15.15/{{ stepca }}"
|
|
|
|
- "https://github.com/smallstep/cli/releases/download/v0.15.16/{{ step }}"
|
|
|
|
|
|
|
|
- name: extract Packages
|
|
|
|
unarchive:
|
|
|
|
src: "/opt/ansiblepackages/{{ item }}"
|
|
|
|
dest: /opt/ansiblepackages
|
|
|
|
remote_src: yes
|
|
|
|
with_items:
|
|
|
|
- "{{ step }}"
|
|
|
|
- "{{ stepca }}"
|
|
|
|
|
2021-06-06 16:51:31 +02:00
|
|
|
- name: copy binaries
|
2021-05-30 01:00:24 +02:00
|
|
|
copy:
|
2021-06-06 16:51:31 +02:00
|
|
|
src: "{{ item.src }}"
|
|
|
|
dest: "{{ item.dst }}"
|
2021-05-30 01:00:24 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
2021-06-06 16:51:31 +02:00
|
|
|
mode: '0755'
|
2021-06-06 18:05:09 +02:00
|
|
|
backup: no
|
|
|
|
remote_src: yes
|
2021-05-30 01:00:24 +02:00
|
|
|
with_items:
|
2021-06-06 18:48:25 +02:00
|
|
|
- { src: "/opt/ansiblepackages/step_0.15.16/bin/step", dst: "/usr/bin/step" }
|
|
|
|
- { src: "/opt/ansiblepackages/step-ca_0.15.15/bin/step-ca", dst: "/usr/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
|
|
|
|
2021-06-06 18:48:25 +02:00
|
|
|
- name: init step-ca
|
|
|
|
command: sudo -u step 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
|
|
|
|
args:
|
|
|
|
creates: /etc/step-ca/.step/config
|
|
|
|
|
2021-05-30 01:00:24 +02:00
|
|
|
- name: set permissions correct
|
|
|
|
file:
|
|
|
|
dest: /etc/step-ca
|
|
|
|
owner: step
|
|
|
|
group: step
|
|
|
|
mode: "0770"
|
|
|
|
recurse: yes
|
|
|
|
|
|
|
|
- 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-06-06 18:48:25 +02:00
|
|
|
- name: correct ca.json step 1
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/step-ca/.step/config/ca.json
|
|
|
|
line: "{{'\t'}}{{'\t'}}\"type\": \"badgerV2\","
|
|
|
|
state: present
|
|
|
|
regexp: "^{{'\t'}}{{'\t'}}\"type\": \"badger\","
|
|
|
|
notify:
|
|
|
|
- restart step-ca
|
|
|
|
|
|
|
|
- name: correct ca.json step 2
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/step-ca/.step/config/ca.json
|
|
|
|
line: "{{'\t'}}{{'\t'}}\"badgerFileLoadingMode\": \"FileIO\""
|
|
|
|
state: present
|
|
|
|
regexp: "^{{'\t'}}{{'\t'}}\"badgerFileLoadingMode\":"
|
|
|
|
notify:
|
|
|
|
- restart step-ca
|
|
|
|
|
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
|
|
|
|
2021-06-06 16:51:31 +02:00
|
|
|
- name: check for acme privisioner
|
|
|
|
lineinfile:
|
2021-06-06 17:32:53 +02:00
|
|
|
path: /etc/step-ca/.step/config/ca.json
|
2021-06-06 16:51:31 +02:00
|
|
|
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
|
2021-06-06 17:32:53 +02:00
|
|
|
command: sudo -u step step ca provisioner add acme --type ACME
|
2021-06-06 16:51:31 +02:00
|
|
|
when: acmepresent is changed
|
2021-05-30 19:43:31 +02:00
|
|
|
notify:
|
|
|
|
- restart step-ca
|
|
|
|
|
2021-06-06 16:51:31 +02:00
|
|
|
- name: check for default JWK privisioner
|
|
|
|
lineinfile:
|
2021-06-06 17:32:53 +02:00
|
|
|
path: /etc/step-ca/.step/config/ca.json
|
2021-06-06 16:51:31 +02:00
|
|
|
regexp: '.*"type": "JWK",.*'
|
|
|
|
line: "{{'\t'}}{{'\t'}}{{'\t'}}{{'\t'}}\"type\": \"JWK\","
|
2021-06-06 17:32:53 +02:00
|
|
|
state: absent
|
2021-06-06 16:51:31 +02:00
|
|
|
check_mode: yes
|
2021-06-06 17:32:53 +02:00
|
|
|
register: jwkabsent
|
2021-06-06 16:51:31 +02:00
|
|
|
|
2021-05-30 19:43:31 +02:00
|
|
|
- name: remove jwk provisioner
|
2021-06-06 17:32:53 +02:00
|
|
|
command: sudo -u step step ca provisioner remove "{{ pki_name }}" --type JWK
|
|
|
|
when: jwkabsent is changed
|
2021-05-30 19:43:31 +02:00
|
|
|
notify:
|
2021-06-06 16:51:31 +02:00
|
|
|
- restart step-ca
|