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

68 lines
1.5 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
2023-04-16 15:35:22 +00:00
- name: Allow 'sudo' group to have passwordless sudo
2023-02-26 09:35:39 +00:00
lineinfile:
path: /etc/sudoers
state: present
2023-04-16 15:35:22 +00:00
regexp: '^%sudo'
line: '%sudo ALL=(ALL) NOPASSWD: ALL'
2023-02-26 09:35:39 +00:00
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-04-08 12:49:34 +00:00
update_cache: yes
- name: uninstall unneeded packages
apt:
name:
- rpcbind
update_cache: yes
state: absent