Handle idempotency
This commit is contained in:
parent
e7968d488d
commit
dbdfda3c48
@ -73,6 +73,15 @@
|
|||||||
register: git_auth_keys
|
register: git_auth_keys
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
|
- name: Check if the public key is already in place
|
||||||
|
lineinfile:
|
||||||
|
path: /var/lib/gitea/git/.ssh/authorized_keys
|
||||||
|
regexp: "^{{ git_id_rsa_pub.stdout }}"
|
||||||
|
state: absent
|
||||||
|
check_mode: true
|
||||||
|
changed_when: false
|
||||||
|
register: git_id_rsa_pub_check
|
||||||
|
|
||||||
- name: Ensure git public key is in gitea loaded authorized_keys
|
- name: Ensure git public key is in gitea loaded authorized_keys
|
||||||
blockinfile:
|
blockinfile:
|
||||||
path: /var/lib/gitea/git/.ssh/authorized_keys
|
path: /var/lib/gitea/git/.ssh/authorized_keys
|
||||||
@ -85,6 +94,7 @@
|
|||||||
backup: true
|
backup: true
|
||||||
marker: "# ansible inserted git <-> gitea public key"
|
marker: "# ansible inserted git <-> gitea public key"
|
||||||
become: true
|
become: true
|
||||||
|
when: git_id_rsa_pub_check.found
|
||||||
|
|
||||||
- name: Symlink the gitea authorized keys configuration to the host git user
|
- name: Symlink the gitea authorized keys configuration to the host git user
|
||||||
file:
|
file:
|
||||||
|
Reference in New Issue
Block a user