role-utilizadores-ansol #7

Merged
hugopeixoto merged 4 commits from role-utilizadores-ansol into master 2022-03-06 15:06:12 +00:00
3 changed files with 42 additions and 0 deletions

View File

@ -4,6 +4,7 @@
become: true become: true
roles: roles:
- fail2ban - fail2ban
- utilizadores
tasks: tasks:
- name: PREPS -- install needed packages - name: PREPS -- install needed packages
become: true become: true

View File

@ -0,0 +1,6 @@
---
utilizadores:
- name: tc
github: tcarrondo
- name: hugopeixoto
github: hugopeixoto

View File

@ -0,0 +1,35 @@
---
# Grupo ansoladm
- name: Create group 'ansoladm'
group:
name: ansoladm
state: present
- name: 'Allow ansoladm users to sudo without a password'
lineinfile:
dest: '/etc/sudoers'
state: 'present'
regexp: '^%ansoladm'
line: '%ansoladm ALL=(ALL) NOPASSWD: ALL'
# Utilizadores e chaves
- name: Add user(s)
become: true
user:
name: '{{ item.name }}'
shell: /bin/bash
groups:
- ansoladm
- lxd
append: yes
with_items:
- '{{utilizadores}}'
- name: Add authorized key(s)
become: true
authorized_key:
user: '{{ item.name }}'
state: present
key: https://github.com/{{ item.github }}.keys
with_items:
- '{{utilizadores}}'