0
Fork 0
mirror of https://github.com/dani-garcia/vaultwarden.git synced 2025-04-01 02:42:49 -05:00

add preinstall ansible role

This commit is contained in:
Sudoix 2025-01-08 10:15:09 +01:00
parent b2b3396563
commit 2972e48188
2 changed files with 103 additions and 0 deletions

View file

@ -0,0 +1,55 @@
- name: Upgrade system
apt:
upgrade: yes
update_cache: true
state: latest
- name: Install necessary tools
apt:
name:
- vim
- sudo
- wget
- curl
- telnet
- nload
- ca-certificates
state: latest
- name: Fix broken packages
apt:
state: fixed
- name: Ensure the /etc/apt/keyrings directory exists
file:
path: /etc/apt/keyrings
state: directory
mode: '0755'
owner: root
group: root
- name: Add Docker GPG key
get_url:
url: "{{ docker_gpg_key_url }}/gpg"
dest: "{{ docker_gpg_key_path }}"
- name: Determine the architecture
command: dpkg --print-architecture
register: architecture
- name: Add Docker APT repository
apt_repository:
repo: "deb [arch={{ architecture.stdout }} signed-by={{ docker_gpg_key_path }}] {{ docker_gpg_key_url }} {{ ansible_distribution_release }} stable"
state: present
update_cache: true
- name: Install docker and docker compose
apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-compose
- docker-buildx-plugin
- docker-compose-plugin
state: present

View file

@ -0,0 +1,48 @@
---
# tasks file for preinstall
- name: Set timezone to UTC
timezone:
name: Etc/UTC
- name: Set hostname
command: hostnamectl set-hostname {{ inventory_hostname }}
- name: Add hostname
lineinfile:
path: /etc/hosts
regexp: '^127\.0\.0\.1'
line: "127.0.0.1 {{ inventory_hostname }} localhost"
owner: root
group: root
mode: 0644
- name: Add hostname
lineinfile:
path: /etc/hosts
regexp: '^127\.0\.1\.1'
line: "127.0.0.1 {{ inventory_hostname }} localhost"
owner: root
group: root
mode: 0644
- name: Add host entries dynamically
lineinfile:
path: /etc/hosts
line: "{{ hostvars[item].private_ip }} {{ item}} {{ item }}.{{ domain }}"
state: present
loop: "{{ groups['all'] }}"
when: hostvars[item].private_ip is defined
- name: Create directory for docker container data
file:
path: "{{ docker_data_path }}"
state: directory
# Basic setup tasks for each distro
- name: Debian basic setup
include_tasks: basic-deb.yml
when: ansible_os_family == 'Debian'
- name: RHEL basic setup
include_tasks: basic-rhel.yml
when: ansible_os_family == 'RedHat'