[Test ongoing]

This commit is contained in:
2025-11-11 16:01:01 +01:00
parent 41c820f1fa
commit 4f6f82c0ef
4 changed files with 147 additions and 152 deletions

1
.gitignore vendored
View File

@@ -6,3 +6,4 @@ SecLists/
scan/ scan/
dirsearch/ dirsearch/
reports/ reports/
bw.yml

View File

@@ -4,6 +4,8 @@ callback_whitelist = timer, profile_tasks, log_plays
#log_path= /var/log/ansible/ansible-base.log #log_path= /var/log/ansible/ansible-base.log
display_args_to_stdout= true display_args_to_stdout= true
load_callback_plugins= yes load_callback_plugins= yes
# [ssh_connection]
# pipelining = True
#callback_plugins=/Users/stephanegratias/Library/Python/3.11/lib/python/site-packages/ara/plugins/callback #callback_plugins=/Users/stephanegratias/Library/Python/3.11/lib/python/site-packages/ara/plugins/callback
#to keep display output, comment stdout_callback #to keep display output, comment stdout_callback
#stdout_callback= log_plays #stdout_callback= log_plays

View File

@@ -3,6 +3,8 @@
# become: true # become: true
gather_facts: false gather_facts: false
vars: vars:
# Variables depuis Environment (non-sensibles)
app_env: "{{ lookup('env', 'test') }}"
dockerapps_path: /opt/dockerapps dockerapps_path: /opt/dockerapps
gitea_conf: /appdata/gitea/gitea/ gitea_conf: /appdata/gitea/gitea/
gitea_db: /appdata/gitea/gitea-db/gitea-db-pg.sql gitea_db: /appdata/gitea/gitea-db/gitea-db-pg.sql
@@ -22,166 +24,167 @@
###! DOCKER COMPOSE FILE ###! DOCKER COMPOSE FILE
############ ############
# - debug: - debug:
# msg: "test ok" msg: "{{ app_env }}"
# delegate_to: localhost delegate_to: localhost
#! fin test
# - name: Return all secrets from a path # - name: Return all secrets from a path
# delegate_to: localhost # delegate_to: localhost
# ansible.builtin.debug: # ansible.builtin.debug:
# msg: "{{ lookup('community.hashi_vault.hashi_vault', 'secret=apps/data/postgres token=prout url=https://hash.jingoh.fr') }}" # msg: "{{ lookup('community.hashi_vault.hashi_vault', 'secret=apps/data/postgres token=prout url=https://hash.jingoh.fr') }}"
- ansible.builtin.git: # - ansible.builtin.git:
repo: https://{{ user }}:{{ token }}@gitea.jingoh.fr/{{ user }}/backup.git # repo: https://{{ user }}:{{ token }}@gitea.jingoh.fr/{{ user }}/backup.git
dest: "{{ playbook_dir }}/backup" # dest: "{{ playbook_dir }}/backup"
single_branch: yes # single_branch: yes
force: true # force: true
delegate_to: localhost # delegate_to: localhost
- ansible.builtin.fetch: # - ansible.builtin.fetch:
src: "{{ item }}" # src: "{{ item }}"
dest: "{{ playbook_dir }}/backup/" # dest: "{{ playbook_dir }}/backup/"
register: fetch_files_backup # register: fetch_files_backup
loop: # loop:
#! Docker-compose # #! Docker-compose
- /opt/dockerapps/docker-compose.yml # - /opt/dockerapps/docker-compose.yml
# #! Dex & traefik-forward # # #! Dex & traefik-forward
# - /opt/dockerapps/appdata/dex/config.yml # # - /opt/dockerapps/appdata/dex/config.yml
# - /opt/dockerapps/appdata/dex/traefik-auth-conf.env # # - /opt/dockerapps/appdata/dex/traefik-auth-conf.env
#! Gitea & Runner # #! Gitea & Runner
- /opt/dockerapps/appdata/gitea/gitea/gitea/conf/app.ini # - /opt/dockerapps/appdata/gitea/gitea/gitea/conf/app.ini
- /opt/dockerapps/appdata/gitea/runner/config.yaml # - /opt/dockerapps/appdata/gitea/runner/config.yaml
# - /opt/dockerapps/appdata/gitea/runner/act_runner/.runner # # - /opt/dockerapps/appdata/gitea/runner/act_runner/.runner
#! Notification # #! Notification
- /opt/dockerapps/appdata/alert/config/alertmanager.yml # - /opt/dockerapps/appdata/alert/config/alertmanager.yml
#! Homepage # #! Homepage
- /opt/dockerapps/appdata/homepage/homepage/bookmarks.yaml # - /opt/dockerapps/appdata/homepage/homepage/bookmarks.yaml
- /opt/dockerapps/appdata/homepage/homepage/services.yaml # - /opt/dockerapps/appdata/homepage/homepage/services.yaml
- /opt/dockerapps/appdata/homepage/homepage/settings.yaml # - /opt/dockerapps/appdata/homepage/homepage/settings.yaml
#! Semaphore # #! Semaphore
- /opt/dockerapps/appdata/semaphore/config/config.json # - /opt/dockerapps/appdata/semaphore/config/config.json
#! Alertmanager # #! Alertmanager
- /opt/dockerapps/appdata/alertmanager/config/alertmanager.yml # - /opt/dockerapps/appdata/alertmanager/config/alertmanager.yml
#! ALertmanager 2 ntfy # #! ALertmanager 2 ntfy
- /opt/dockerapps/appdata/ntfy_alertmanager/etc/config # - /opt/dockerapps/appdata/ntfy_alertmanager/etc/config
#! Grafana # #! Grafana
- /opt/dockerapps/appdata/grafana/grafana.ini # - /opt/dockerapps/appdata/grafana/grafana.ini
- /opt/dockerapps/appdata/grafana/ldap.toml # - /opt/dockerapps/appdata/grafana/ldap.toml
#! prometheus # #! prometheus
- /opt/dockerapps/appdata/prometheus/prometheus/prometheus.yml # - /opt/dockerapps/appdata/prometheus/prometheus/prometheus.yml
- /opt/dockerapps/appdata/prometheus/prometheus/alerts_system.yml # - /opt/dockerapps/appdata/prometheus/prometheus/alerts_system.yml
- /opt/dockerapps/appdata/prometheus/prometheus/alerts_network.yml # - /opt/dockerapps/appdata/prometheus/prometheus/alerts_network.yml
# - /opt/dockerapps/appdata/prometheus/prometheus/alerts_internal.yml # # - /opt/dockerapps/appdata/prometheus/prometheus/alerts_internal.yml
- /opt/dockerapps/appdata/prometheus/prometheus/promtool_test.yml # - /opt/dockerapps/appdata/prometheus/prometheus/promtool_test.yml
# #! bind # # #! bind
# - /opt/dockerapps/appdata/bind/config/named.conf # # - /opt/dockerapps/appdata/bind/config/named.conf
# - /opt/dockerapps/appdata/bind/records/example.com.zone # # - /opt/dockerapps/appdata/bind/records/example.com.zone
# - /opt/dockerapps/appdata/bind/records/jingoh.private.zone # # - /opt/dockerapps/appdata/bind/records/jingoh.private.zone
# #! crowdsec # # #! crowdsec
# - /opt/dockerapps/appdata/crowdsec/crowdsec/parsers/s01-parse/tcpudp-flood-traefik.yaml # # - /opt/dockerapps/appdata/crowdsec/crowdsec/parsers/s01-parse/tcpudp-flood-traefik.yaml
# - /opt/dockerapps/appdata/crowdsec/crowdsec/acquis.yaml # # - /opt/dockerapps/appdata/crowdsec/crowdsec/acquis.yaml
# - /opt/dockerapps/appdata/crowdsec/dashboard/docker/Dockerfile # # - /opt/dockerapps/appdata/crowdsec/dashboard/docker/Dockerfile
# #! filebeat (kafka) # # #! filebeat (kafka)
# - /opt/dockerapps/appdata/kafka/filebeat.yml # # - /opt/dockerapps/appdata/kafka/filebeat.yml
#! ldap # #! ldap
- /opt/dockerapps/appdata/ldap/data/lldap_config.toml # - /opt/dockerapps/appdata/ldap/data/lldap_config.toml
#! sftp # #! sftp
- /opt/dockerapps/appdata/sftp/config/sftpgo.json # - /opt/dockerapps/appdata/sftp/config/sftpgo.json
#! vault_sync_ldap # #! vault_sync_ldap
- /opt/dockerapps/appdata/vault_sync_ldap/jingoh.config.toml # - /opt/dockerapps/appdata/vault_sync_ldap/jingoh.config.toml
#! vault # #! vault
- /opt/dockerapps/appdata/vaultwarden/config.json # - /opt/dockerapps/appdata/vaultwarden/config.json
#! wg portal # #! wg portal
- /opt/dockerapps/appdata/wg-portal/config/config.yml # - /opt/dockerapps/appdata/wg-portal/config/config.yml
# #! wg portal # # #! wg portal
# - /opt/dockerapps/appdata/mailserver/etc/config.toml # # - /opt/dockerapps/appdata/mailserver/etc/config.toml
#! gatus # #! gatus
- /opt/dockerapps/appdata/gatus/config.yml # - /opt/dockerapps/appdata/gatus/config.yml
#! syncthing # #! syncthing
- /opt/dockerapps/appdata/syncthing/config/config.xml # - /opt/dockerapps/appdata/syncthing/config/config.xml
#! authelia # #! authelia
- /opt/dockerapps/appdata/authelia/config/configuration.yml # - /opt/dockerapps/appdata/authelia/config/configuration.yml
- name: Push backup to git # - name: Push backup to git
ansible.builtin.shell: | # ansible.builtin.shell: |
git config user.email "{{ user_mail }}" # git config user.email "{{ user_mail }}"
git config user.name "{{ user }}" # git config user.name "{{ user }}"
git add . # git add .
git commit -m "Push Backup with access token" # git commit -m "Push Backup with access token"
git push https://{{ user }}:{{ token }}@gitea.jingoh.fr/{{ user }}/backup.git # git push https://{{ user }}:{{ token }}@gitea.jingoh.fr/{{ user }}/backup.git
args: # args:
chdir: "{{ playbook_dir }}/backup/" # chdir: "{{ playbook_dir }}/backup/"
run_once: true # run_once: true
delegate_to: localhost # delegate_to: localhost
############# # #############
#! GITEA # #! GITEA
############ # ############
- ansible.builtin.file: # - ansible.builtin.file:
path: "{{ dockerapps_path }}/backup/gitea" # path: "{{ dockerapps_path }}/backup/gitea"
state: directory # state: directory
# mode: '0755' # # mode: '0755'
#/opt/dockerapps/appdata/gitea/gitea/gitea-dump-*.zip # #/opt/dockerapps/appdata/gitea/gitea/gitea-dump-*.zip
- name: DUMP gitea conf # - name: DUMP gitea conf
community.docker.docker_container_exec: # community.docker.docker_container_exec:
container: gitea # container: gitea
command: gitea dump -c /data/gitea/conf/app.ini # command: gitea dump -c /data/gitea/conf/app.ini
user: git # user: git
chdir: /data # chdir: /data
- ansible.builtin.find: # - ansible.builtin.find:
paths: "{{ dockerapps_path }}{{ gitea_conf }}" # paths: "{{ dockerapps_path }}{{ gitea_conf }}"
patterns: 'gitea-dump-*.zip' # patterns: 'gitea-dump-*.zip'
register: result_gitea_conf # register: result_gitea_conf
- name: Print stdout # - name: Print stdout
ansible.builtin.debug: # ansible.builtin.debug:
var: result_gitea_conf # var: result_gitea_conf
- name: Copy file with owner and permissions # - name: Copy file with owner and permissions
ansible.builtin.copy: # ansible.builtin.copy:
src: "{{ item.path }}" # src: "{{ item.path }}"
dest: "{{ dockerapps_path }}/backup/gitea/{{ item.path.split('/')[-1]}}" # dest: "{{ dockerapps_path }}/backup/gitea/{{ item.path.split('/')[-1]}}"
remote_src: true # remote_src: true
loop: "{{ result_gitea_conf.files }}" # loop: "{{ result_gitea_conf.files }}"
# owner: foo # # owner: foo
# group: foo # # group: foo
# mode: '0644' # # mode: '0644'
- name: Remove old gitea-dump # - name: Remove old gitea-dump
ansible.builtin.file: # ansible.builtin.file:
path: "{{ item.path }}" # path: "{{ item.path }}"
state: absent # state: absent
loop: "{{ result_gitea_conf.files }}" # loop: "{{ result_gitea_conf.files }}"
#! need root # #! need root
# root@scaleway:/opt/dockerapps/appdata/gitea/gitea-db/gitea-db-pg.sql # # root@scaleway:/opt/dockerapps/appdata/gitea/gitea-db/gitea-db-pg.sql
- name: PG_DUMP postgresql db # - name: PG_DUMP postgresql db
community.docker.docker_container_exec: # community.docker.docker_container_exec:
container: gitea-db # container: gitea-db
command: pg_dump -U root gitea -f /var/lib/postgresql/data/gitea-db-pg.sql # command: pg_dump -U root gitea -f /var/lib/postgresql/data/gitea-db-pg.sql
# chdir: "{{ dockerapps_path }}" # # chdir: "{{ dockerapps_path }}"
register: result_gitea_db # register: result_gitea_db
- ansible.builtin.debug: # - ansible.builtin.debug:
var: result_gitea_db.stdout # var: result_gitea_db.stdout
- name: Copy file with owner and permissions # - name: Copy file with owner and permissions
become: true # become: true
ansible.builtin.copy: # ansible.builtin.copy:
src: "{{ dockerapps_path }}{{ gitea_db }}" # src: "{{ dockerapps_path }}{{ gitea_db }}"
dest: "{{ dockerapps_path }}/backup/gitea/{{ gitea_db.split('/')[-1] }}" # dest: "{{ dockerapps_path }}/backup/gitea/{{ gitea_db.split('/')[-1] }}"
remote_src: true # remote_src: true
- ansible.builtin.file: # - ansible.builtin.file:
path: "{{ dockerapps_path }}/backup" # path: "{{ dockerapps_path }}/backup"
state: directory # state: directory
mode: 0755 # mode: 0755
recurse: true # recurse: true
become: true # become: true

View File

@@ -1,11 +0,0 @@
#! wake up runner !
- hosts: tower
gather_facts: false
tasks:
- ansible.builtin.file:
path: /opt/dockerapps/appdata/jelly
state: directory
recurse: yes
mode: '777'
become: true
become_user: root