risotto/ansible/host.yml

102 lines
2.3 KiB
YAML
Raw Normal View History

2022-10-01 22:33:11 +02:00
---
- name: "Populate service facts"
service_facts:
2023-06-22 16:12:09 +02:00
- name: "Set timezone"
timezone:
name: Europe/Paris
- name: Set a hostname
ansible.builtin.hostname:
name: "{{ inventory_hostname }}"
- name: "Install packages"
2022-10-01 22:33:11 +02:00
apt:
pkg: "{{ vars[inventory_hostname]['general']['host_packages'] }}"
update_cache: yes
state: latest
- name: "Remove packages"
apt:
pkg: "{{ vars[inventory_hostname]['general']['host_removed_packages'] }}"
update_cache: yes
state: absent
- name: "Add keyrings directory"
file:
path: /etc/apt/keyrings
state: directory
mode: "755"
- name: "Add vector signed repositories"
ansible.builtin.get_url:
url: https://repositories.timber.io/public/vector/gpg.3543DB2D0A2BC4B8.key
dest: /etc/apt/keyrings/vector.asc
- name: "Add vector repository"
ansible.builtin.apt_repository:
repo: "deb [signed-by=/etc/apt/keyrings/vector.asc] https://repositories.timber.io/public/vector/deb/debian {{ ansible_distribution_release }} main"
state: present
- name: "Install vector"
ansible.builtin.apt:
name: vector
update_cache: yes
state: present
2023-01-23 20:23:32 +01:00
- name: "Host is modified"
include_tasks: host_modified.yml
when: build_host.host_changed
2022-10-01 22:33:11 +02:00
- name: "Copy machines scripts"
ansible.builtin.copy:
src: "{{ item }}"
dest: "/usr/local/sbin"
owner: "root"
group: "root"
mode: "0755"
2022-12-21 16:35:58 +01:00
loop: "{{ lookup('fileglob', 'sbin/*', wantlist=True) | list }}"
2022-10-01 22:33:11 +02:00
- name: "Remove dest images files"
file:
path: /var/lib/risotto/images_files
2023-01-23 20:23:32 +01:00
state: "{{ item }}"
2022-10-01 22:33:11 +02:00
mode: "0700"
2023-01-23 20:23:32 +01:00
with_items:
- absent
- directory
2022-10-01 22:33:11 +02:00
- name: "Copy images files"
unarchive:
2023-01-23 20:23:32 +01:00
remote_src: true
src: "/tmp/new_configurations/images_files.tar"
2022-10-01 22:33:11 +02:00
dest: "/var/lib/risotto/images_files"
2022-12-21 16:35:58 +01:00
- name: "Create versions directory"
file:
2023-01-23 20:23:32 +01:00
path: /var/lib/risotto/machines_informations
2022-12-21 16:35:58 +01:00
state: directory
mode: "0700"
2023-01-23 20:23:32 +01:00
- name: "Empty tests files"
file:
path: /var/lib/risotto/tests
state: "{{ item }}"
mode: "0700"
with_items:
- absent
- directory
- name: "Copy tests files"
unarchive:
remote_src: true
src: "/tmp/new_configurations/tests.tar"
dest: "/var/lib/risotto/tests"
when: copy_tests
2023-02-27 14:03:56 +01:00
- name: "Create TLS directory"
file:
path: /var/lib/risotto/tls
state: directory
mode: "755"