diff --git a/README.md b/README.md index c572c5aab0caf515bfa772226da448c0d4bc2727..b63af0dfbfaec72bd9bfb2df57b359dac639d6a4 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A -- very simple -- Ansible playbook that adds a new local user to `utility[\d+] Example usage of this playbook: ``` -ansible-playbook -i 127.0.0.1, playbook.yml -e "username=$USERNAME" -e "full_name=$YOUR_NAME" -k +ansible-playbook -i 127.0.0.1, playbook.yml -e "username=$USERNAME" -e "full_name=$YOUR_NAME" -e "ssh_key_path=$YOUR_SSH_KEY" -k ``` -Remember to fill in the variables `$USERNAME` and `$YOUR_NAME` +Remember to fill in the variables `$USERNAME`, `$YOUR_NAME`, and `$YOUR_SSH_KEY`. diff --git a/roles/gap_utility_user/tasks/main.yml b/roles/gap_utility_user/tasks/main.yml index f705e9ae4e03e964b4da2d502bc9ba9248ee2040..fd0e439b85b2f91d1dc6d66a017c9d5a8540bbff 100644 --- a/roles/gap_utility_user/tasks/main.yml +++ b/roles/gap_utility_user/tasks/main.yml @@ -4,11 +4,15 @@ comment: "{{ full_name }}" groups: sudo append: yes - # generate_ssh_key: yes - # ssh_key_bits: 4096 - # ssh_key_comment: "{{ username }}'s key" + password: '!' # Do not allow login with a password + password_lock: yes # Login with SSH key only register: user_output +- name: Add SSH key to user for logging in + ansible.posix.authorized_key: + user: "{{ username }}" + key: "{{ ssh_key_path }}" + - name: Create new VM for development ansible.builtin.debug: msg: "Now, provision a new VM using Terraform"