update ansible roles

This commit is contained in:
James Hackett 2023-03-18 14:04:55 +00:00
parent 33fb23933f
commit 8019d50f06
No known key found for this signature in database
GPG key ID: 8DC0850668B1568B
6 changed files with 56 additions and 25 deletions

View file

@ -8,6 +8,11 @@ apt_packages:
- nmap - nmap
- sysstat - sysstat
- vim - vim
- gnupg
- software-properties-common
- psmisc
- sudo
- mosh
apt_install_packages: false apt_install_packages: false
apt_update_packages: true apt_update_packages: true

View file

@ -41,25 +41,3 @@
enabled: yes enabled: yes
state: started state: started
when: ansible_check_mode == false when: ansible_check_mode == false
- name: Check nomad status
become: true
shell: nomad status
register: nomad_status
when: ansible_check_mode == false
- name: Print nomad status
debug:
msg: '{{ nomad_status.stdout }}'
when: ansible_check_mode == false
- name: Check nomad members
become: true
shell: nomad server members
register: nomad_members
when: ansible_check_mode == false
- name: Print nomad members
debug:
msg: '{{ nomad_members.stdout }}'
when: ansible_check_mode == false

View file

@ -6,6 +6,9 @@ github_users:
- user: mojito - user: mojito
# omitting account variable won't add any github keys to the user. # omitting account variable won't add any github keys to the user.
account: DistroByte account: DistroByte
groups: [sudo, docker] groups: [sudo]
- user: slatt
account: cawnj
groups: [sudo]
github_url: https://github.com github_url: https://github.com

View file

@ -17,16 +17,39 @@
with_items: "{{ github_users }}" with_items: "{{ github_users }}"
- name: Ensure authorized_keys for GitHub user accounts are present - name: Ensure authorized_keys for GitHub user accounts are present
become: true
authorized_key: authorized_key:
user: "{{ item.user | default(item) }}" user: "{{ item.user | default(item) }}"
key: "{{ github_url }}/{{ item.account | default('') }}.keys" key: "{{ github_url }}/{{ item.account | default('') }}.keys"
manage_dir: true manage_dir: true
state: present
exclusive: False exclusive: False
with_items: "{{ github_users }}" with_items: "{{ github_users }}"
ignore_errors: yes ignore_errors: true
register: task_result register: task_result
failed_when: "'blah' in task_result" failed_when: "'blah' in task_result"
- name: Tell user to generate openVPN configuration for users - name: Tell user to generate openVPN configuration for users
debug: debug:
msg: "Please generate openVPN configuration for users: {{ task_result.results | map(attribute='item') | map(attribute='user') | list | join(', ') }}. See https://docs.redbrick.dcu.ie/aperture/vpn/ for more information." msg: "Please generate openVPN configuration for users: {{ task_result.results | map(attribute='item') | map(attribute='user') | list | join(', ') }}. See https://docs.redbrick.dcu.ie/aperture/vpn/ for more information."
- name: Copy configuraion to host
become: true
ansible.builtin.copy:
src: templates/sshd_config.j2
dest: /etc/ssh/sshd_config
force: true
- name: Restart sshd
become: true
service:
name: sshd
state: restarted
- name: Inform user to add password for account
debug:
msg: "Please add a password for the following accounts: {{ github_users | map(attribute='user') | list | join(', ') }}. See https://docs.redbrick.dcu.ie/aperture/ssh/ for more information."
# - name: Remove user account
# debug:
# msg: 'ansible -i hosts all -m user -a "name={{ user }} state=absent remove=true" --become"'

View file

@ -15,4 +15,4 @@ plugin "docker" {
enabled = true enabled = true
} }
} }
} }

View file

@ -0,0 +1,22 @@
Include /etc/ssh/sshd_config.d/*.conf
ChallengeResponseAuthentication no
UsePAM no
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
Port 22
PermitRootLogin no
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
PasswordAuthentication yes
PermitEmptyPasswords no
GSSAPIAuthentication no
AuthenticationMethods publickey,password
Match address 10.10.0.0/24,10.8.0.0/24,10.230.0.0/16,136.206.15.0/24,136.206.16.0/24
AuthenticationMethods publickey password