Skip to content

Commit

Permalink
operator: add operator_authorized_github_accounts parameter
Browse files Browse the repository at this point in the history
Supports a list of Github accounts from which the public keys are added to
the authorized keys.

Related to SovereignCloudStack/issues#433

Signed-off-by: Christian Berendt <berendt@osism.tech>
  • Loading branch information
berendt committed Sep 21, 2023
1 parent df86e1b commit c453455
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions roles/operator/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ The default shell for the operator.

A list of ssh authorized keys to add.

.. zuul:rolevar:: operator_authorized_github_accounts
:default: []

List of Github accounts from which the public keys are added to the authorized keys.

.. zuul:rolevar:: operator_password
Encrypted password string to set for the operator user (optional).
Expand Down
1 change: 1 addition & 0 deletions roles/operator/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ operator_group_id: 45000
operator_shell: /bin/bash

operator_authorized_keys: []
operator_authorized_github_accounts: []

# NOTE: Use "mkpasswd --method=sha-512" to generate a password
# operator_password:
Expand Down
8 changes: 8 additions & 0 deletions roles/operator/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@
loop: "{{ operator_authorized_keys }}"
no_log: true

- name: Set authorized github accounts
become: true
ansible.posix.authorized_key:
key: "{{ lookup('url', 'https://github.com/' + item + '.keys', split_lines=False) }}"
user: "{{ operator_user }}"
loop: "{{ operator_authorized_github_accounts }}"
no_log: true

- name: Set password of operator user
become: true
ansible.builtin.user:
Expand Down

0 comments on commit c453455

Please sign in to comment.