2 changed files with 103 additions and 0 deletions
@ -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 |
@ -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' |
Loading…
Reference in new issue