infra-role-github-webhook/tasks/user.yml

41 lines
1.3 KiB
YAML

---
- name: Create webhook group
group:
name: '{{ github_webhook_service_user }}'
gid: '{{ github_webhook_service_user_uid }}'
- name: Create webhook user
user:
name: '{{ github_webhook_service_user }}'
group: '{{ github_webhook_service_user }}'
groups: '{{ github_webhook_service_user_groups }}'
uid: '{{ github_webhook_service_user_uid }}'
create_home: true
comment: 'Airflow Webhook User'
- name: Create SSH config directory
file:
path: '{{ github_webhook_home }}/.ssh'
owner: '{{ github_webhook_service_user }}'
group: '{{ github_webhook_service_user }}'
state: 'directory'
mode: 0750
when: github_webhook_ssh_key is defined
# The field content need the literral block style ( `|` ) to keep the EOF at the end and ensure the validity of the key.
- name: Create SSH private key
copy:
dest: '{{ github_webhook_home }}/.ssh/id_rsa'
content: |
{{ github_webhook_ssh_key }}
owner: '{{ github_webhook_service_user }}'
group: '{{ github_webhook_service_user }}'
mode: 0400
when: github_webhook_ssh_key is defined
- name: Update give webhook user permission to directory
file:
path: '{{ github_webhook_dest_path }}'
owner: '{{ github_webhook_service_user }}'
group: '{{ github_webhook_service_user }}'