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

80 lines
1.6 KiB
YAML
Raw Normal View History

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
# pub key files in /files/USER.key.pub
#
- 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
2023-03-02 19:25:22 +00:00
- libndp0
- libndp-tools
- ndppd
- iptables-persistent
2023-02-26 09:35:39 +00:00
state: latest
2023-03-02 19:25:22 +00:00
update_cache: yes
#
# Copy ndppd Config
#
- name: Generate NDPPD Config
ansible.builtin.template:
src: ndppd.conf.j2
dest: /etc/ndppd.conf
owner: root
group: root
mode: 755