Compare commits
3 Commits
6a3804dd86
...
526ec984cc
| Author | SHA1 | Date | |
|---|---|---|---|
| 526ec984cc | |||
| 9128da538e | |||
| 2d378d51a7 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
|||||||
|
ansible/.ansible
|
||||||
|
ansible/.ansible-lint
|
||||||
*.swp
|
*.swp
|
||||||
|
|||||||
4
ansible/ansible-lint
Normal file
4
ansible/ansible-lint
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
skip_list:
|
||||||
|
- yaml[line-length]
|
||||||
@ -1,10 +1,10 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
private_networks: ""
|
bastion_private_networks: ""
|
||||||
allowed_networks: ""
|
bastion_allowed_networks: ""
|
||||||
fail2ban_ignore_ips: ""
|
bastion_fail2ban_ignore_ips: ""
|
||||||
|
|
||||||
dev_users: []
|
bastion_dev_users: []
|
||||||
admin_users: []
|
bastion_admin_users: []
|
||||||
rundeck_users: []
|
bastion_rundeck_users: []
|
||||||
log_server: ""
|
bastion_log_server: ""
|
||||||
|
|||||||
@ -1,25 +1,25 @@
|
|||||||
---
|
---
|
||||||
- name: reload nftables
|
- name: Reload nftables
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: nftables
|
name: nftables
|
||||||
state: reloaded
|
state: reloaded
|
||||||
|
|
||||||
- name: reload fail2ban
|
- name: Reload fail2ban
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: fail2ban
|
name: fail2ban
|
||||||
state: reloaded
|
state: reloaded
|
||||||
|
|
||||||
- name: restart fail2ban
|
- name: Restart fail2ban
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: fail2ban
|
name: fail2ban
|
||||||
state: restart
|
state: restarted
|
||||||
|
|
||||||
- name: restart ssh
|
- name: Restart ssh
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
service: sshd
|
service: sshd
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
- name: restart rsyslog
|
- name: Restart rsyslog
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
service: rsyslog
|
service: rsyslog
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|||||||
@ -1,44 +1,46 @@
|
|||||||
- name: ensure nftables service is started and enabled
|
---
|
||||||
|
|
||||||
|
- name: Ensure nftables service is started and enabled
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: nftables
|
name: nftables
|
||||||
state: started
|
state: started
|
||||||
enabled: true
|
enabled: true
|
||||||
tags: all,firewall
|
tags: all,firewall
|
||||||
|
|
||||||
- name: deploying nftables configuration
|
- name: Deploying nftables configuration
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: nftables.conf.j2
|
src: nftables.conf.j2
|
||||||
dest: /etc/nftables.conf
|
dest: /etc/nftables.conf
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: '0755'
|
mode: "0755"
|
||||||
backup: true
|
backup: true
|
||||||
validate: "nft -c -f %s"
|
validate: "nft -c -f %s"
|
||||||
notify:
|
notify:
|
||||||
- reload nftables
|
- Reload nftables
|
||||||
- restart fail2ban
|
- Restart fail2ban
|
||||||
tags: all,firewall
|
tags: all,firewall
|
||||||
|
|
||||||
- name: ensure fail2ban is installed
|
- name: Ensure fail2ban is installed
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: fail2ban
|
name: fail2ban
|
||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
tags: all,firewall
|
tags: all,firewall
|
||||||
|
|
||||||
- name: ensure fail2ban is enabled and running
|
- name: Ensure fail2ban is enabled and running
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: fail2ban
|
name: fail2ban
|
||||||
state: started
|
state: started
|
||||||
enabled: true
|
enabled: true
|
||||||
tags: all,firewall
|
tags: all,firewall
|
||||||
|
|
||||||
- name: deploying fail2ban ssh conf
|
- name: Deploying fail2ban ssh conf
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: sshd.conf.j2
|
src: sshd.conf.j2
|
||||||
dest: /etc/fail2ban/jail.d/sshd.conf
|
dest: /etc/fail2ban/jail.d/sshd.conf
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: '0644'
|
mode: "0644"
|
||||||
notify: reload fail2ban
|
notify: reload fail2ban
|
||||||
tags: all,firewall
|
tags: all,firewall
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: user deployment related tasks
|
- name: User deployment related tasks
|
||||||
include_tasks: users.yml
|
ansible.builtin.include_tasks: users.yml
|
||||||
tags: all,users,rootonly
|
tags: all,users,rootonly
|
||||||
|
|
||||||
- name: firewall deployment related tasks
|
- name: Firewall deployment related tasks
|
||||||
include_tasks: firewall.yml
|
ansible.builtin.include_tasks: firewall.yml
|
||||||
tags: all,firewall
|
tags: all,firewall
|
||||||
|
|
||||||
- name: ssh deployment related tasks
|
- name: Ssh deployment related tasks
|
||||||
include_tasks: ssh.yml
|
ansible.builtin.include_tasks: ssh.yml
|
||||||
tags: all,ssh
|
tags: all,ssh
|
||||||
|
|||||||
@ -1,28 +1,28 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: ensure sshd is enabled
|
- name: Ensure sshd is enabled
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: sshd
|
name: sshd
|
||||||
enabled: true
|
enabled: true
|
||||||
tags: all,ssh
|
tags: all,ssh
|
||||||
|
|
||||||
- name: deploy sshd_config
|
- name: Deploy sshd_config
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: sshd_config.j2
|
src: sshd_config.j2
|
||||||
dest: /etc/ssh/sshd_config
|
dest: /etc/ssh/sshd_config
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
validate: "sshd -T -f %s"
|
validate: "sshd -T -f %s"
|
||||||
notify: restart ssh
|
notify: Restart ssh
|
||||||
tags: all,ssh
|
tags: all,ssh
|
||||||
|
|
||||||
- name: deploy rsyslog conf
|
- name: Deploy rsyslog conf
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: auth.conf.j2
|
src: auth.conf.j2
|
||||||
dest: /etc/rsyslog.d/auth.conf
|
dest: /etc/rsyslog.d/auth.conf
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
notify: restart rsyslog
|
notify: Restart rsyslog
|
||||||
tags: all,ssh
|
tags: all,ssh
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: installing sudo
|
- name: Installing sudo
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: sudo
|
name: sudo
|
||||||
update_cache: true
|
update_cache: true
|
||||||
state: present
|
state: present
|
||||||
tags: all,users
|
tags: all,users
|
||||||
|
|
||||||
- name: adding targetpw directive for sudo
|
- name: Adding targetpw directive for sudo
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/sudoers
|
path: /etc/sudoers
|
||||||
line: "{{ item }}"
|
line: "{{ item }}"
|
||||||
@ -17,37 +17,37 @@
|
|||||||
- "Defaults insults"
|
- "Defaults insults"
|
||||||
tags: all,users
|
tags: all,users
|
||||||
|
|
||||||
- name: creating admin users
|
- name: Creating admin users
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: "{{ item.username }}"
|
name: "{{ item.username }}"
|
||||||
shell: /bin/bash
|
shell: /bin/bash
|
||||||
groups: sudo
|
groups: sudo
|
||||||
with_items: "{{ admin_users }}"
|
with_items: "{{ bastion_admin_users }}"
|
||||||
tags: all,users
|
tags: all,users
|
||||||
|
|
||||||
- name: creating dev users
|
- name: Creating dev users
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: "{{ item.username }}"
|
name: "{{ item.username }}"
|
||||||
shell: /bin/bash
|
shell: /bin/bash
|
||||||
groups: sudo
|
groups: sudo
|
||||||
with_items: "{{ dev_users }}"
|
with_items: "{{ bastion_dev_users }}"
|
||||||
tags: all,users
|
tags: all,users
|
||||||
|
|
||||||
- name: adding authorized_keys for regular users
|
- name: Adding authorized_keys for regular users
|
||||||
ansible.builtin.authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: "{{ item.username }}"
|
user: "{{ item.username }}"
|
||||||
key: "{{ item.public_key }}"
|
key: "{{ item.public_key }}"
|
||||||
state: "{{ item.state | default('present') }}"
|
state: "{{ item.state | default('present') }}"
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ admin_users }}"
|
- "{{ bastion_admin_users }}"
|
||||||
- "{{ dev_users }}"
|
- "{{ bastion_dev_users }}"
|
||||||
tags: all,users
|
tags: all,users
|
||||||
|
|
||||||
- name: adding authorized_keys for root users
|
- name: Adding authorized_keys for root users
|
||||||
ansible.builtin.authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: "root"
|
user: "root"
|
||||||
key: "{{ item.public_key }}"
|
key: "{{ item.public_key }}"
|
||||||
key_options: 'from="{{ private_networks }}"'
|
key_options: 'from="{{ bastion_private_networks }}"'
|
||||||
state: "{{ item.state }}"
|
state: "{{ item.state }}"
|
||||||
with_items: "{{ admin_users }}"
|
with_items: "{{ bastion_admin_users }}"
|
||||||
tags: all,users,rootonly
|
tags: all,users,rootonly
|
||||||
|
|||||||
@ -1,16 +1,16 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: restart containerd
|
- name: Restart containerd
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: containerd
|
name: containerd
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
- name: restart docker
|
- name: Restart docker
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: docker
|
name: docker
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
- name: restart multipathd
|
- name: Restart multipathd
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: multipathd
|
name: multipathd
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
- name: set specific variables for distributions
|
---
|
||||||
include_vars: '{{ item }}'
|
|
||||||
|
- name: Set specific variables for distributions
|
||||||
|
ansible.builtin.include_vars: '{{ item }}'
|
||||||
with_first_found:
|
with_first_found:
|
||||||
- '{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml'
|
- '{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml'
|
||||||
- '{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml'
|
- '{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml'
|
||||||
@ -9,7 +11,7 @@
|
|||||||
- default.yml
|
- default.yml
|
||||||
|
|
||||||
- name: Suppression anciennes versions de docker
|
- name: Suppression anciennes versions de docker
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
pkg:
|
pkg:
|
||||||
- docker
|
- docker
|
||||||
- docker-engine
|
- docker-engine
|
||||||
@ -17,7 +19,7 @@
|
|||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
- name: Installation des prérequis
|
- name: Installation des prérequis
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
pkg:
|
pkg:
|
||||||
- apt-transport-https
|
- apt-transport-https
|
||||||
- ca-certificates
|
- ca-certificates
|
||||||
@ -26,40 +28,46 @@
|
|||||||
- software-properties-common
|
- software-properties-common
|
||||||
- nfs-common
|
- nfs-common
|
||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
update_cache: true
|
||||||
|
|
||||||
- name: Ajout de la clef GPG docker.com
|
- name: Ajout de la clef GPG docker.com
|
||||||
apt_key:
|
ansible.builtin.apt_key:
|
||||||
url: https://download.docker.com/linux/ubuntu/gpg
|
url: https://download.docker.com/linux/ubuntu/gpg
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Ajout du repo APT docker.com
|
- name: Ajout du repo APT docker.com
|
||||||
apt_repository:
|
ansible.builtin.apt_repository:
|
||||||
repo: deb [arch=amd64] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable
|
repo: deb [arch=amd64] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable
|
||||||
state: present
|
state: present
|
||||||
filename: docker
|
filename: docker
|
||||||
|
|
||||||
- name: Installation de docker dans la version {{ target_version }}
|
- name: Installation de docker dans la version {{ docker_target_version }}
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
pkg:
|
pkg:
|
||||||
- docker-ce={{ target_version }}
|
- docker-ce={{ docker_target_version }}
|
||||||
- docker-ce-cli={{ target_version }}
|
- docker-ce-cli={{ docker_target_version }}
|
||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
update_cache: true
|
||||||
register: apt_out
|
register: apt_out
|
||||||
|
|
||||||
- name: Affichage sortie du module apt
|
- name: Affichage sortie du module apt
|
||||||
debug:
|
ansible.builtin.debug:
|
||||||
msg:
|
msg:
|
||||||
- "{{ apt_out.stdout_lines }}"
|
- "{{ apt_out.stdout_lines }}"
|
||||||
- "{{ apt_out.stderr_lines }}"
|
- "{{ apt_out.stderr_lines }}"
|
||||||
ignore_errors: yes
|
failed_when: apt_out.rc != 0
|
||||||
|
|
||||||
- name: Verrouillage des paquets docker-ce
|
- name: Verrouillage des paquets docker-ce
|
||||||
command: apt-mark hold docker-ce docker-ce-cli containerd.io
|
ansible.builtin.dpkg_selections:
|
||||||
|
name: "{{ item }}"
|
||||||
|
selection: hold
|
||||||
|
with_items:
|
||||||
|
- docker-ce
|
||||||
|
- docker-ce-cli
|
||||||
|
- containerd.io
|
||||||
|
|
||||||
- name: adding cleaning cron
|
- name: Adding cleaning cron
|
||||||
cron:
|
ansible.builtin.cron:
|
||||||
minute: "0"
|
minute: "0"
|
||||||
hour: "0"
|
hour: "0"
|
||||||
job: "/usr/bin/docker image prune -a -f >/dev/null 2>&1"
|
job: "/usr/bin/docker image prune -a -f >/dev/null 2>&1"
|
||||||
@ -97,8 +105,8 @@
|
|||||||
dest: /etc/containerd/config.toml
|
dest: /etc/containerd/config.toml
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: '0755'
|
mode: "0755"
|
||||||
notify: restart containerd
|
notify: Restart containerd
|
||||||
|
|
||||||
- name: Customise docker file daemon.json
|
- name: Customise docker file daemon.json
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@ -106,8 +114,8 @@
|
|||||||
dest: /etc/docker/daemon.json
|
dest: /etc/docker/daemon.json
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: '0755'
|
mode: "0755"
|
||||||
notify: restart docker
|
notify: Restart docker
|
||||||
|
|
||||||
- name: Adding Multipathd blacklist for longhorn support
|
- name: Adding Multipathd blacklist for longhorn support
|
||||||
ansible.builtin.blockinfile:
|
ansible.builtin.blockinfile:
|
||||||
@ -117,15 +125,15 @@
|
|||||||
blacklist {
|
blacklist {
|
||||||
devnode "^sd[a-z0-9]+"
|
devnode "^sd[a-z0-9]+"
|
||||||
}
|
}
|
||||||
notify: restart multipathd
|
notify: Restart multipathd
|
||||||
|
|
||||||
- name: start and enable iscsi daemon for longhorn support
|
- name: Start and enable iscsi daemon for longhorn support
|
||||||
ansible.builtin.systemd_service:
|
ansible.builtin.systemd_service:
|
||||||
name: iscsid
|
name: iscsid
|
||||||
enabled: true
|
enabled: true
|
||||||
state: started
|
state: started
|
||||||
|
|
||||||
- name: enable iscsi_tcp kernel module for longhorn support
|
- name: Enable iscsi_tcp kernel module for longhorn support
|
||||||
community.general.modprobe:
|
community.general.modprobe:
|
||||||
name: iscsi_tcp
|
name: iscsi_tcp
|
||||||
state: present
|
state: present
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
target_version: "5:24.0.7-1~debian.12~bookworm"
|
docker_target_version: "5:24.0.7-1~debian.12~bookworm"
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
target_version: "5:18.09.9~3-0~ubuntu-bionic"
|
docker_target_version: "5:18.09.9~3-0~ubuntu-bionic"
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
target_version: "5:20.10.9~3-0~ubuntu-focal"
|
docker_target_version: "5:20.10.9~3-0~ubuntu-focal"
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
target_version: "5:20.10.23~3-0~ubuntu-jammy"
|
docker_target_version: "5:20.10.23~3-0~ubuntu-jammy"
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
target_version: "5:27.5.1-1~ubuntu.24.04~noble"
|
docker_target_version: "5:27.5.1-1~ubuntu.24.04~noble"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user