upated role step-ca

This commit is contained in:
Alexander Gabriel 2021-06-06 16:32:53 +01:00
parent 683a3446f0
commit 9b5d32d43b
2 changed files with 25 additions and 39 deletions

View File

@ -28,25 +28,6 @@
group: step group: step
mode: "0770" mode: "0770"
- 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
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 - name: set permissions correct
file: file:
dest: /etc/step-ca dest: /etc/step-ca
@ -55,14 +36,19 @@
mode: "0770" mode: "0770"
recurse: yes recurse: yes
- name: correct paths - name: init step-ca
replace: 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
path: "{{ item }}" args:
regexp: '\/root\/.step' creates: /etc/step-ca/.step/config
replace: "\/etc\/step-ca"
with_items: - name: correct badgerValueLogLoadingMode
- /etc/step-ca/config/ca.json lineinfile:
- /etc/step-ca/config/defaults.json path: /etc/step-ca/.step/config/ca.json
line: "{{'\t'}}{{'\t'}},\"badgerValueLogLoadingMode\": \"FileIO\""
state: present
insertafter: "{{'\t'}}{{'\t'}}\"badgerFileLoadingMode\": \"\""
notify:
- restart step-ca
- name: generate /etc/systemd/system/step-ca.service - name: generate /etc/systemd/system/step-ca.service
template: template:
@ -90,7 +76,7 @@
- name: check for acme privisioner - name: check for acme privisioner
lineinfile: lineinfile:
path: /etc/step-ca/config/ca.json path: /etc/step-ca/.step/config/ca.json
regexp: '.*"type": "ACME",.*' regexp: '.*"type": "ACME",.*'
line: "{{'\t'}}{{'\t'}}{{'\t'}}{{'\t'}}\"type\": \"ACME\"," line: "{{'\t'}}{{'\t'}}{{'\t'}}{{'\t'}}\"type\": \"ACME\","
state: present state: present
@ -98,22 +84,22 @@
register: acmepresent register: acmepresent
- name: add acme provisioner - name: add acme provisioner
command: step ca provisioner add acme --type ACME command: sudo -u step step ca provisioner add acme --type ACME
when: acmepresent is changed when: acmepresent is changed
notify: notify:
- restart step-ca - restart step-ca
- name: check for default JWK privisioner - name: check for default JWK privisioner
lineinfile: lineinfile:
path: /etc/step-ca/config/ca.json path: /etc/step-ca/.step/config/ca.json
regexp: '.*"type": "JWK",.*' regexp: '.*"type": "JWK",.*'
line: "{{'\t'}}{{'\t'}}{{'\t'}}{{'\t'}}\"type\": \"JWK\"," line: "{{'\t'}}{{'\t'}}{{'\t'}}{{'\t'}}\"type\": \"JWK\","
state: present state: absent
check_mode: yes check_mode: yes
register: jwkpresent register: jwkabsent
- name: remove jwk provisioner - name: remove jwk provisioner
command: step ca provisioner remove "{{ pki_name }}" --type JWK command: sudo -u step step ca provisioner remove "{{ pki_name }}" --type JWK
when: jwkpresent is not changed when: jwkabsent is changed
notify: notify:
- restart step-ca - restart step-ca

View File

@ -6,16 +6,16 @@ After=network-online.target
Wants=network-online.target Wants=network-online.target
StartLimitIntervalSec=30 StartLimitIntervalSec=30
StartLimitBurst=3 StartLimitBurst=3
ConditionFileNotEmpty=/etc/step-ca/config/ca.json ConditionFileNotEmpty=/etc/step-ca/.step/config/ca.json
ConditionFileNotEmpty=/etc/step-ca/password.txt ConditionFileNotEmpty=/etc/step-ca/password.txt
[Service] [Service]
Type=simple Type=simple
User=step User=step
Group=step Group=step
Environment=STEPPATH=/etc/step-ca Environment=STEPPATH=/etc/step-ca/.step
WorkingDirectory=/etc/step-ca WorkingDirectory=/etc/step-ca/.step
ExecStart=/usr/bin/step-ca config/ca.json --password-file password.txt ExecStart=/usr/bin/step-ca config/ca.json --password-file ../password.txt
ExecReload=/bin/kill --signal HUP $MAINPID ExecReload=/bin/kill --signal HUP $MAINPID
Restart=on-failure Restart=on-failure
RestartSec=5 RestartSec=5
@ -48,7 +48,7 @@ RestrictRealtime=true
SystemCallFilter=@system-service SystemCallFilter=@system-service
SystemCallArchitectures=native SystemCallArchitectures=native
MemoryDenyWriteExecute=true MemoryDenyWriteExecute=true
ReadWriteDirectories=/etc/step-ca/db ReadWriteDirectories=/etc/step-ca/.step/db
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target