2022-01-25 23:54:43 -06:00
|
|
|
---
|
|
|
|
###
|
|
|
|
# This role installs the basic package and host setup for AniNIX operations.
|
|
|
|
|
|
|
|
# This is an AniNIX convention to allow password management by Ansible.
|
2023-05-02 17:32:11 -05:00
|
|
|
|
|
|
|
- name: Test root password
|
|
|
|
ignore_errors: yes
|
|
|
|
register: root_password_test
|
|
|
|
vars:
|
|
|
|
ansible_become_user: "{{ item }}"
|
|
|
|
ansible_become_method: su
|
|
|
|
ansible_become_password: "{{ passwords[inventory_hostname] }}"
|
|
|
|
become: yes
|
|
|
|
command: id
|
|
|
|
loop:
|
|
|
|
- root
|
|
|
|
- "{{ ansible_user_id }}"
|
|
|
|
|
|
|
|
- name: Define passwords
|
|
|
|
ignore_errors: yes
|
|
|
|
vars:
|
|
|
|
ansible_become_user: "root"
|
|
|
|
ansible_become_password: "{{ passwords[inventory_hostname] }}"
|
|
|
|
become: yes
|
|
|
|
when: root_password_test.rc is not defined or root_password_test.rc != 0
|
|
|
|
command:
|
|
|
|
cmd: /bin/bash -l -c "echo '{{item}}:{{ passwords[inventory_hostname] }}' | chpasswd {{ item }}"
|
|
|
|
loop:
|
|
|
|
- root
|
|
|
|
- "{{ ansible_user_id }}"
|
|
|
|
|
2022-01-25 23:54:43 -06:00
|
|
|
- name: Base packages
|
|
|
|
vars:
|
|
|
|
ansible_become_method: su
|
|
|
|
ansible_become_password: "{{ passwords[inventory_hostname] }}"
|
|
|
|
become: yes
|
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- bash
|
|
|
|
- sudo
|
|
|
|
- git
|
|
|
|
- tmux
|
|
|
|
- vim
|
|
|
|
- sysstat
|
|
|
|
- iotop
|
|
|
|
- lsof
|
|
|
|
- rsync
|
2022-05-25 14:50:16 -05:00
|
|
|
- xfsprogs
|
2022-01-25 23:54:43 -06:00
|
|
|
state: present
|
|
|
|
update_cache: yes
|
|
|
|
|
|
|
|
- name: Ensure deploy user has sudo permissions.
|
|
|
|
vars:
|
|
|
|
ansible_become_method: su
|
|
|
|
ansible_become_password: "{{ passwords[inventory_hostname] }}"
|
|
|
|
become: yes
|
|
|
|
copy:
|
|
|
|
dest: /etc/sudoers.d/basics
|
|
|
|
content: "{{ ansible_user_id }} ALL=(ALL) NOPASSWD: ALL\n"
|
|
|
|
|
|
|
|
- name: Ensure we include /etc/sudoers.d (Current)
|
|
|
|
vars:
|
|
|
|
ansible_become_method: su
|
|
|
|
ansible_become_password: "{{ passwords[inventory_hostname] }}"
|
|
|
|
become: yes
|
|
|
|
when: ansible_architecture != "armv6l"
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/sudoers
|
|
|
|
regexp: "includedir /etc/sudoers.d"
|
|
|
|
line: "@includedir /etc/sudoers.d"
|
|
|
|
|
|
|
|
- name: Ensure we include /etc/sudoers.d (Legacy)
|
|
|
|
vars:
|
|
|
|
ansible_become_method: su
|
|
|
|
ansible_become_password: "{{ passwords[inventory_hostname] }}"
|
|
|
|
become: yes
|
|
|
|
when: ansible_architecture == "armv6l"
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/sudoers
|
|
|
|
regexp: "includedir /etc/sudoers.d"
|
|
|
|
line: "#includedir /etc/sudoers.d"
|
|
|
|
|
|
|
|
- name: Set up pacman.conf
|
|
|
|
vars:
|
|
|
|
ansible_become_password: "{{ passwords[inventory_hostname] }}"
|
2023-10-08 12:28:14 -05:00
|
|
|
ignorepkg: "{{ holdpackages | default('') }}"
|
2022-01-25 23:54:43 -06:00
|
|
|
become: yes
|
2023-10-08 12:28:14 -05:00
|
|
|
template:
|
|
|
|
src: pacman.conf.j2
|
2022-01-25 23:54:43 -06:00
|
|
|
dest: /etc/pacman.conf
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
when: ansible_os_family == "Archlinux"
|
|
|
|
|
2023-11-30 02:47:16 -06:00
|
|
|
- name: Set mirror
|
2022-01-25 23:54:43 -06:00
|
|
|
become: yes
|
|
|
|
when: ansible_os_family == "Archlinux"
|
|
|
|
copy:
|
2023-11-30 02:47:16 -06:00
|
|
|
content: |
|
|
|
|
Server = {{ mirroruri }}
|
2022-01-25 23:54:43 -06:00
|
|
|
dest: /etc/pacman.d/mirrorlist.shadowarch
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
|
|
|
|
- name: Set up apt sources.list
|
|
|
|
vars:
|
|
|
|
ansible_become_password: "{{ passwords[inventory_hostname] }}"
|
|
|
|
become: yes
|
|
|
|
copy:
|
|
|
|
content: |
|
2022-05-25 14:50:16 -05:00
|
|
|
deb http://archive.raspberrypi.org/debian/ bullseye main
|
|
|
|
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
|
|
|
|
#deb-src http://archive.raspberrypi.org/debian/ bullseye main
|
|
|
|
dest: /etc/apt/sources.list.d/raspi.list
|
2022-01-25 23:54:43 -06:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
when: ansible_os_family == "Debian"
|
|
|
|
|
|
|
|
- name: Install ShadowArch (ArchLinux)
|
|
|
|
vars:
|
|
|
|
ansible_become_password: "{{ passwords[inventory_hostname] }}"
|
|
|
|
become: yes
|
|
|
|
pacman:
|
|
|
|
name: ShadowArch
|
|
|
|
state: present
|
|
|
|
update_cache: yes
|
|
|
|
when: ansible_os_family == "Archlinux"
|
|
|
|
|
|
|
|
- name: Set up AniNIX-specific repository location (Other)
|
|
|
|
when: ansible_os_family != "Archlinux"
|
|
|
|
vars:
|
|
|
|
ansible_become_password: "{{ passwords[inventory_hostname] }}"
|
|
|
|
become: yes
|
|
|
|
file:
|
|
|
|
path: /opt/aninix
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: Download ShadowArch (Other)
|
|
|
|
vars:
|
|
|
|
ansible_become_password: "{{ passwords[inventory_hostname] }}"
|
|
|
|
become: yes
|
|
|
|
ignore_errors: yes
|
|
|
|
git:
|
|
|
|
repo: 'https://foundation.aninix.net/AniNIX/ShadowArch'
|
|
|
|
dest: '/opt/aninix/ShadowArch'
|
|
|
|
update: yes
|
|
|
|
when: ansible_os_family != "Archlinux"
|
|
|
|
|
|
|
|
- name: Install ShadowArch (Other)
|
|
|
|
vars:
|
|
|
|
ansible_become_password: "{{ passwords[inventory_hostname] }}"
|
|
|
|
become: yes
|
|
|
|
command:
|
|
|
|
chdir: '/opt/aninix/ShadowArch'
|
2023-11-30 02:47:16 -06:00
|
|
|
cmd: '/bin/bash -c "make install"'
|
2022-01-25 23:54:43 -06:00
|
|
|
when: ansible_os_family != "Archlinux"
|
|
|
|
|
|
|
|
- name: Set up hostname
|
|
|
|
vars:
|
|
|
|
ansible_become_password: "{{ passwords[inventory_hostname] }}"
|
|
|
|
become: yes
|
|
|
|
hostname:
|
|
|
|
name: "{{ inventory_hostname }}.{{ replica_domain }}"
|
|
|
|
|
|
|
|
- include: archlinux-network.yml
|
|
|
|
when: ansible_os_family == "Archlinux"
|
|
|
|
|
|
|
|
- include: raspbian-network.yml
|
|
|
|
when: ansible_os_family == "Debian"
|
|
|
|
|
|
|
|
- include: dns.yml
|
|
|
|
|
|
|
|
- include: ntp.yml
|
2022-11-20 20:03:01 -06:00
|
|
|
|
|
|
|
- include: bash.yml
|