ansible.fftdf.supernode/roles/00-ubuntu-basic/tasks/main.yml

61 lines
1.4 KiB
YAML
Raw Normal View History

2023-02-26 09:35:39 +00:00
---
2023-03-04 13:56:15 +00:00
# Set System Hostname
2023-02-26 09:35:39 +00:00
- name: Ensure hostname set
hostname:
name: "{{ inventory_hostname }}"
when: not inventory_hostname|trim is match('(\d{1,3}\.){3}\d{1,3}')
become: yes
register: hostname_set
- name: Reboot host and wait for it to restart
reboot:
msg: "Reboot initiated by Ansible"
connect_timeout: 5
reboot_timeout: 600
pre_reboot_delay: 0
post_reboot_delay: 30
test_command: whoami
when: hostname_set.changed
# Users defined in /vars/main.yml
2023-03-04 13:56:15 +00:00
# pub key files in /files/{USER}.key.pub
2023-02-26 09:35:39 +00:00
- name: "Create user accounts and add users to groups"
user:
name: "{{ item }}"
2023-03-02 19:25:22 +00:00
groups: sudo
2023-02-26 09:35:39 +00:00
with_items: "{{ users }}"
- name: "Add authorized keys"
2023-02-26 09:52:43 +00:00
authorized_key:
user: "{{ item }}"
key: "{{ lookup('file', 'files/'+ item + '.key.pub') }}"
with_items: "{{ users }}"
2023-02-26 09:35:39 +00:00
- name: Allow 'wheel' group to have passwordless sudo
lineinfile:
path: /etc/sudoers
state: present
regexp: '^%wheel'
line: '%wheel ALL=(ALL) NOPASSWD: ALL'
validate: '/usr/sbin/visudo -cf %s'
# Install basic packages for Ubuntu minimal Systems
- name: Install all Packages
ansible.builtin.apt:
name:
- curl
- nano
- vim
- htop
- screen
- iproute2
- iptables
- cron
- qemu-guest-agent
- iputils-ping
- iw
- speedtest-cli
- telnet
state: latest
2023-03-04 13:56:15 +00:00
update_cache: yes