vm-ansible/roles/common/tasks/user-ops.yaml
Kristóf Torma 52f7e7e153
Some checks failed
continuous-integration/drone/push Build is failing
remove fqdn
2023-08-30 23:13:59 +02:00

39 lines
1013 B
YAML

---
- name: Create .ssh directory of ansible user
file:
path: /home/ansible@intra.tormakris.dev/.ssh
state: directory
owner: ansible@intra.tormakris.dev
group: domain users@intra.tormakris.dev
- name: Copy authorized_keys
copy:
src: authorized_keys
dest: /home/ansible@intra.tormakris.dev/.ssh/authorized_keys
mode: 0600
owner: ansible@intra.tormakris.dev
group: domain users@intra.tormakris.dev
- name: Check if group is present in sudoers
lineinfile:
state: absent
path: /etc/sudoers
regexp: "^%linuxadmins"
check_mode: true
changed_when: false
register: checksudoers
- name: Define group in sudoers
lineinfile:
state: present
path: /etc/sudoers
line: "%linuxadmins@intra.tormakris.dev ALL=(ALL) NOPASSWD: ALL"
when: checksudoers.found == 0
- name: "Update authorized_keys of tormakris"
ansible.posix.authorized_key:
user: tormakris@intra.tormakris.dev
state: present
key: https://static.tormakristof.eu/ssh.keys
...