Files
aurbis/playbook.yml
T
2025-01-05 17:02:29 +01:00

76 lines
2.1 KiB
YAML

- name: Provision all hosts
hosts: all
become: true
tasks:
- name: Set hostname
hostname:
name: "{{ inventory_hostname }}"
- name: Print distribution
ansible.builtin.debug:
#var: ansible_facts ansible_distribution_release
var: ansible_distribution_release
- name: Add aurbis group
ansible.builtin.group:
name: aurbis
state: present
- name: Create users
ansible.builtin.user:
name: "{{ item }}"
groups:
- aurbis
- sudo
- wheel
append: true
shell: /bin/bash
state: present
when: users is defined
loop: "{{ users }}"
- name: Add IP address of relevant hosts to /etc/hosts
lineinfile:
dest: /etc/hosts
regexp: ".*{{ item }}$"
line: "{{ hostvars[item].ansible_host }} {{item}}"
state: present
when:
- hostvars[item].ansible_host is defined
- (inventory_hostname in groups['home'] and (item in groups['home'] or item in groups['cloud'])) or
(inventory_hostname not in groups['home'] and item in groups['cloud'])
with_items: "{{ groups.all }}"
- name: Update Debian hosts
hosts: debian
become: true
tasks:
- name: Update
include_tasks: tasks/update_debian.yml
- name: Update Arch hosts
hosts: arch
become: true
tasks:
- name: Update
include_tasks: tasks/update_arch.yml
- name: Docker
hosts: debian
become: true
tasks:
- name: Update
include_tasks: tasks/install_docker_debian.yml
- name: Add utility scripts
hosts: all
become: true
tasks:
- name: Git clone
ansible.builtin.git:
repo: https://git.hoekveen.net/mark/scripts.git
dest: /opt/scripts
force: true
- name: Set permissions and ownership for scripts folder
file:
path: /opt/scripts
state: directory
recurse: true
group: aurbis
mode: "0775"
- name: Add scripts directory to safe.directory
ansible.builtin.command:
cmd: git config --system --add safe.directory /opt/scripts