mirror of
https://gitlab.sectorq.eu/jaydee/ansible.git
synced 2025-12-14 18:04:53 +01:00
Compare commits
2 Commits
6f25202f8a
...
57b714271a
| Author | SHA1 | Date | |
|---|---|---|---|
| 57b714271a | |||
| 19bdbfde78 |
3
all.yml
3
all.yml
@@ -5,6 +5,9 @@
|
|||||||
- name: setup
|
- name: setup
|
||||||
role: setup
|
role: setup
|
||||||
tags: setup
|
tags: setup
|
||||||
|
- name: git
|
||||||
|
role: git
|
||||||
|
tags: git
|
||||||
- name: common
|
- name: common
|
||||||
tags: common
|
tags: common
|
||||||
role: common
|
role: common
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ datacenter:
|
|||||||
rpi5-1.home.lan:
|
rpi5-1.home.lan:
|
||||||
rpi5.home.lan:
|
rpi5.home.lan:
|
||||||
m-server.home.lan:
|
m-server.home.lan:
|
||||||
amd.home.lan:
|
|
||||||
fog.home.lan:
|
fog.home.lan:
|
||||||
zabbix.home.lan:
|
zabbix.home.lan:
|
||||||
|
amd.home.lan:
|
||||||
omv.home.lan:
|
omv.home.lan:
|
||||||
192.168.77.101:
|
192.168.77.101:
|
||||||
vars:
|
vars:
|
||||||
@@ -19,6 +19,7 @@ datacenter:
|
|||||||
identity_file: ssh_key.pem
|
identity_file: ssh_key.pem
|
||||||
ansible_ssh_pass: l4c1j4yd33Du5lo
|
ansible_ssh_pass: l4c1j4yd33Du5lo
|
||||||
ansible_become_user: root
|
ansible_become_user: root
|
||||||
|
amd.home.lan:
|
||||||
nas:
|
nas:
|
||||||
hosts:
|
hosts:
|
||||||
nas.home.lan:
|
nas.home.lan:
|
||||||
|
|||||||
@@ -107,7 +107,19 @@ datacenter:
|
|||||||
ansible_become_password: q
|
ansible_become_password: q
|
||||||
# ansible_ssh_password: q
|
# ansible_ssh_password: q
|
||||||
ansible_ssh_private_key_file: ssh_key.pem
|
ansible_ssh_private_key_file: ssh_key.pem
|
||||||
|
proxmox:
|
||||||
|
children:
|
||||||
|
docker_workers:
|
||||||
|
children:
|
||||||
|
worker1:
|
||||||
|
hosts:
|
||||||
|
192.168.77.184:
|
||||||
|
vars:
|
||||||
|
ansible_ssh_user: jd
|
||||||
|
ansible_become_user: root
|
||||||
|
ansible_become_password: q
|
||||||
|
# ansible_ssh_password: q
|
||||||
|
ansible_ssh_password: q
|
||||||
containers:
|
containers:
|
||||||
children:
|
children:
|
||||||
docker_servers:
|
docker_servers:
|
||||||
|
|||||||
@@ -42,6 +42,67 @@
|
|||||||
when:
|
when:
|
||||||
- ansible_distribution == "Debian" and ansible_distribution_major_version == "12"
|
- ansible_distribution == "Debian" and ansible_distribution_major_version == "12"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Ensure docker keyring directory exists
|
||||||
|
file:
|
||||||
|
path: /etc/apt/keyrings
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Download Docker GPG key
|
||||||
|
get_url:
|
||||||
|
url: https://download.docker.com/linux/debian/gpg
|
||||||
|
dest: /etc/apt/keyrings/docker.asc
|
||||||
|
mode: "0644"
|
||||||
|
when:
|
||||||
|
- ansible_distribution == "Debian" and ansible_distribution_major_version == "13"
|
||||||
|
|
||||||
|
- name: Install docker.sources file
|
||||||
|
template:
|
||||||
|
src: docker.sources.j2
|
||||||
|
dest: /etc/apt/sources.list.d/docker.sources
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
when:
|
||||||
|
- ansible_distribution == "Debian" and ansible_distribution_major_version == "13"
|
||||||
|
|
||||||
|
- name: Create docker.sources file
|
||||||
|
copy:
|
||||||
|
dest: /etc/apt/sources.list.d/docker.sources
|
||||||
|
mode: "0644"
|
||||||
|
content: |
|
||||||
|
Types: deb
|
||||||
|
URIs: https://download.docker.com/linux/debian
|
||||||
|
Suites: {{ ansible_facts['lsb']['codename'] }}
|
||||||
|
Components: stable
|
||||||
|
Signed-By: /etc/apt/keyrings/docker.asc
|
||||||
|
when:
|
||||||
|
- ansible_distribution == "Debian" and ansible_distribution_major_version == "13"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Update apt cache
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
|
when:
|
||||||
|
- ansible_distribution == "Debian" and ansible_distribution_major_version == "13"
|
||||||
|
|
||||||
|
- name: Download Docker GPG key
|
||||||
|
get_url:
|
||||||
|
url: https://download.docker.com/linux/debian/gpg
|
||||||
|
dest: /etc/apt/keyrings/docker.asc
|
||||||
|
mode: "0644"
|
||||||
|
when:
|
||||||
|
- ansible_distribution == "Debian" and ansible_distribution_major_version == "13"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- name: Add an Apt signing key to a specific keyring file
|
- name: Add an Apt signing key to a specific keyring file
|
||||||
ansible.builtin.apt_key:
|
ansible.builtin.apt_key:
|
||||||
url: https://download.docker.com/linux/ubuntu/gpg
|
url: https://download.docker.com/linux/ubuntu/gpg
|
||||||
@@ -84,13 +145,10 @@
|
|||||||
# - docker-buildx-plugin
|
# - docker-buildx-plugin
|
||||||
# - docker-compose-plugin
|
# - docker-compose-plugin
|
||||||
# update_cache: true
|
# update_cache: true
|
||||||
|
- name: Install the version docker1
|
||||||
|
|
||||||
- name: Install the version docker
|
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: "{{ item }}=5:28.5.2-1~{{ ansible_distribution | lower }}.{{ ansible_distribution_major_version }}~{{ ansible_distribution_release }}"
|
name: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
allow_downgrade: true
|
|
||||||
when:
|
when:
|
||||||
- ansible_distribution == "Debian"
|
- ansible_distribution == "Debian"
|
||||||
loop:
|
loop:
|
||||||
@@ -98,7 +156,7 @@
|
|||||||
- docker-ce-cli
|
- docker-ce-cli
|
||||||
- name: Install the version docker
|
- name: Install the version docker
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: "{{ item }}=1.7.28-2~{{ ansible_distribution | lower }}.{{ ansible_distribution_major_version }}~{{ ansible_distribution_release }}"
|
name: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
allow_downgrade: true
|
allow_downgrade: true
|
||||||
when:
|
when:
|
||||||
@@ -108,13 +166,44 @@
|
|||||||
|
|
||||||
- name: Install the version docker
|
- name: Install the version docker
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: "{{ item }}=0.28.0-0~{{ ansible_distribution | lower }}.{{ ansible_distribution_major_version }}~{{ ansible_distribution_release }}"
|
name: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
allow_downgrade: true
|
allow_downgrade: true
|
||||||
when:
|
when:
|
||||||
- ansible_distribution == "Debian"
|
- ansible_distribution == "Debian"
|
||||||
loop:
|
loop:
|
||||||
- docker-buildx-plugin
|
- docker-buildx-plugin
|
||||||
|
|
||||||
|
|
||||||
|
- name: Install the version docker
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: "{{ item }}=5:28.5.2-1~{{ ansible_distribution | lower }}.{{ ansible_distribution_major_version }}~{{ ansible_distribution_release }}"
|
||||||
|
state: present
|
||||||
|
allow_downgrade: true
|
||||||
|
when:
|
||||||
|
- ansible_distribution == "Debian1"
|
||||||
|
loop:
|
||||||
|
- docker-ce
|
||||||
|
- docker-ce-cli
|
||||||
|
- name: Install the version docker
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: "{{ item }}=1.7.28-2~{{ ansible_distribution | lower }}.{{ ansible_distribution_major_version }}~{{ ansible_distribution_release }}"
|
||||||
|
state: present
|
||||||
|
allow_downgrade: true
|
||||||
|
when:
|
||||||
|
- ansible_distribution == "Debian1"
|
||||||
|
loop:
|
||||||
|
- containerd.io
|
||||||
|
|
||||||
|
- name: Install the version docker
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: "{{ item }}=0.28.0-0~{{ ansible_distribution | lower }}.{{ ansible_distribution_major_version }}~{{ ansible_distribution_release }}"
|
||||||
|
state: present
|
||||||
|
allow_downgrade: true
|
||||||
|
when:
|
||||||
|
- ansible_distribution == "Debian1"
|
||||||
|
loop:
|
||||||
|
- docker-buildx-plugin
|
||||||
|
|
||||||
- name: Create a directory docker.service.d
|
- name: Create a directory docker.service.d
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
|
|||||||
@@ -26,3 +26,8 @@
|
|||||||
path: "/etc/hosts"
|
path: "/etc/hosts"
|
||||||
regexp: "^192.168.77.55 .*"
|
regexp: "^192.168.77.55 .*"
|
||||||
line: "192.168.77.55 rack rack.home.lan"
|
line: "192.168.77.55 rack rack.home.lan"
|
||||||
|
- name: Reconfigure hosts file
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: "/etc/hosts"
|
||||||
|
regexp: "^193.168.144.164 .*"
|
||||||
|
line: "193.168.144.164 external"
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
- name: Omv Setup
|
- name: Omv Setup
|
||||||
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
block:
|
block:
|
||||||
|
# - name: Gather facts
|
||||||
|
# ansible.builtin.setup:
|
||||||
|
# - name: Print
|
||||||
|
# ansible.builtin.debug:
|
||||||
|
# msg: "{{ ansible_facts }}"
|
||||||
- name: Include vault
|
- name: Include vault
|
||||||
ansible.builtin.include_vars:
|
ansible.builtin.include_vars:
|
||||||
file: jaydee.yml
|
file: jaydee.yml
|
||||||
@@ -10,6 +15,21 @@
|
|||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
state: absent
|
state: absent
|
||||||
path: "{{ dest_folder }}"
|
path: "{{ dest_folder }}"
|
||||||
|
|
||||||
|
- name: "Check if listed package is installed or not on Debian Linux family"
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: present
|
||||||
|
check_mode: true
|
||||||
|
loop:
|
||||||
|
- git
|
||||||
|
register: git_installed
|
||||||
|
|
||||||
|
- name: Include role only if missing
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: git
|
||||||
|
when: not git_installed
|
||||||
|
|
||||||
- name: Pull repo
|
- name: Pull repo
|
||||||
tags:
|
tags:
|
||||||
- git_pull
|
- git_pull
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ Host nas
|
|||||||
Host router
|
Host router
|
||||||
HostName router.home.lan
|
HostName router.home.lan
|
||||||
User root
|
User root
|
||||||
|
Host external
|
||||||
|
HostName 193.168.144.164
|
||||||
|
User root
|
||||||
Host *
|
Host *
|
||||||
User jd
|
User jd
|
||||||
IdentityFile ~/.ssh/id_rsa
|
IdentityFile ~/.ssh/id_rsa
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
- name: SSH keys deploy
|
- name: SSH keys deploy
|
||||||
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
block:
|
block:
|
||||||
|
- name: Create dir
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /home/jd/.ssh
|
||||||
|
owner: jd
|
||||||
|
group: jd
|
||||||
|
mode: '0700'
|
||||||
|
state: directory
|
||||||
- name: Upload key
|
- name: Upload key
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: id_rsa
|
src: id_rsa
|
||||||
@@ -11,7 +18,7 @@
|
|||||||
when: inventory_hostname != 'nas.home.lan'
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
- name: Upload key
|
- name: Upload key
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: id_rsa
|
src: id_rsa.pub
|
||||||
dest: /home/jd/.ssh/id_rsa.pub
|
dest: /home/jd/.ssh/id_rsa.pub
|
||||||
mode: '0600'
|
mode: '0600'
|
||||||
owner: jd
|
owner: jd
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
- ansible_facts.architecture != "armv7l"
|
- ansible_facts.architecture != "armv7l"
|
||||||
- ansible_facts.architecture != "aarch64"
|
- ansible_facts.architecture != "aarch64"
|
||||||
- ansible_distribution == "Debian"
|
- ansible_distribution == "Debian"
|
||||||
- ansible_distribution_major_version == "12"
|
- ansible_distribution_major_version == "13"
|
||||||
register: command_result
|
register: command_result
|
||||||
failed_when: "'FAILED' in command_result.stderr"
|
failed_when: "'FAILED' in command_result.stderr"
|
||||||
# - name: Install a .deb package localy
|
# - name: Install a .deb package localy
|
||||||
|
|||||||
Reference in New Issue
Block a user