From 4151d0b348747c98430a0202e16f8cab0d7d0e23 Mon Sep 17 00:00:00 2001 From: donotos <37663674+donotos@users.noreply.github.com> Date: Sun, 5 Sep 2021 19:31:17 +0200 Subject: [PATCH] migrate from github --- collections/requirements.yaml | 3 +++ git_pull.yml | 11 ++++++++++ linux_update.yml | 10 +++++++++ linux_update_omv.yml | 11 ++++++++++ linux_update_ynh.yml | 16 ++++++++++++++ pritunl_restart_service.yml | 9 ++++++++ reboot.yml | 8 +++++++ test.yml | 15 +++++++++++++ vmware_create_snapshot.yml | 16 ++++++++++++++ zabbix_add_script.yml | 40 +++++++++++++++++++++++++++++++++++ 10 files changed, 139 insertions(+) create mode 100644 collections/requirements.yaml create mode 100644 git_pull.yml create mode 100644 linux_update.yml create mode 100644 linux_update_omv.yml create mode 100644 linux_update_ynh.yml create mode 100644 pritunl_restart_service.yml create mode 100644 reboot.yml create mode 100644 test.yml create mode 100644 vmware_create_snapshot.yml create mode 100644 zabbix_add_script.yml diff --git a/collections/requirements.yaml b/collections/requirements.yaml new file mode 100644 index 0000000..6138440 --- /dev/null +++ b/collections/requirements.yaml @@ -0,0 +1,3 @@ +--- +collections: +- name: community.vmware diff --git a/git_pull.yml b/git_pull.yml new file mode 100644 index 0000000..ce5a5af --- /dev/null +++ b/git_pull.yml @@ -0,0 +1,11 @@ +--- +- name: Git pull + hosts: all + + tasks: + + - name: pull "{{ git_dest }}" + git: + repo: "{{ git_repo }}" + dest: "{{ git_dest }}" + update: yes diff --git a/linux_update.yml b/linux_update.yml new file mode 100644 index 0000000..5aa4373 --- /dev/null +++ b/linux_update.yml @@ -0,0 +1,10 @@ +--- +- name: Upgrade all packages to the latest version + hosts: all + + tasks: + + - name: Upgrade all packages to the latest version + apt: + update_cache: yes + upgrade: yes diff --git a/linux_update_omv.yml b/linux_update_omv.yml new file mode 100644 index 0000000..18879f7 --- /dev/null +++ b/linux_update_omv.yml @@ -0,0 +1,11 @@ +- name: Update OpenMediaVault + hosts: all + + tasks: + - name: On execute la commande "omv-update" + shell: + cmd: omv-update + + - name: On applique la configuration + shell: + cmd: '/usr/sbin/omv-rpc -u admin "config" "applyChanges" "{ \"modules\": $(cat /var/lib/openmediavault/dirtymodules.json),\"force\": true }"' diff --git a/linux_update_ynh.yml b/linux_update_ynh.yml new file mode 100644 index 0000000..929b6e8 --- /dev/null +++ b/linux_update_ynh.yml @@ -0,0 +1,16 @@ +--- +- name: Update Yunohost + hosts: all + + tasks: + - name: On execute la commande "dpkg --configure -a" + shell: + cmd: dpkg --configure -a + + - name: On execute la commande "yunohost tools update" + shell: + cmd: yunohost tools update + + - name: On execute la commande "yunohost tools upgrade --system" + shell: + cmd: yunohost tools upgrade --system diff --git a/pritunl_restart_service.yml b/pritunl_restart_service.yml new file mode 100644 index 0000000..519b1b0 --- /dev/null +++ b/pritunl_restart_service.yml @@ -0,0 +1,9 @@ +--- +- name: Redemarrer le service pritunl. + hosts: all + + tasks: + - name: Redemarrer le process "pritunl" + systemd: + name: pritunl + state: restarted diff --git a/reboot.yml b/reboot.yml new file mode 100644 index 0000000..2b2838d --- /dev/null +++ b/reboot.yml @@ -0,0 +1,8 @@ +--- +- name: Reboot + hosts: all + + tasks: + + - name: Reboot {{ inventory_hostname }} + reboot: diff --git a/test.yml b/test.yml new file mode 100644 index 0000000..aa3cb70 --- /dev/null +++ b/test.yml @@ -0,0 +1,15 @@ +--- +- name: Update Yunohost + hosts: all + + tasks: + - name: On fait un snapshot de la VM + community.vmware.vmware_guest_snapshot: + hostname: "{{ lookup('env', 'VMWARE_HOST') }}" + username: "{{ lookup('env', 'VMWARE_USER') }}" + password: "{{ lookup('env', 'VMWARE_PASSWORD') }}" + datacenter: "{{ datacenter_name }}" + uuid: "{{ vm_uuid }}" + state: present + snapshot_name: pre_auto_update + delegate_to: localhost diff --git a/vmware_create_snapshot.yml b/vmware_create_snapshot.yml new file mode 100644 index 0000000..536dc4c --- /dev/null +++ b/vmware_create_snapshot.yml @@ -0,0 +1,16 @@ +--- +- name: Create/Remove snapshot without ram. + hosts: all + + tasks: + - name: On crée/supprime un snapshot sur la VM + community.vmware.vmware_guest_snapshot: + hostname: "{{ lookup('env', 'VMWARE_HOST') }}" + username: "{{ lookup('env', 'VMWARE_USER') }}" + password: "{{ lookup('env', 'VMWARE_PASSWORD') }}" + datacenter: "{{ esxi_host }}" + uuid: "{{ vm_uuid }}" + state: "{{ snap_state }}" + snapshot_name: "{{ snap_name }}" + description: "{{ snap_descr }}" + delegate_to: localhost diff --git a/zabbix_add_script.yml b/zabbix_add_script.yml new file mode 100644 index 0000000..0a9bc88 --- /dev/null +++ b/zabbix_add_script.yml @@ -0,0 +1,40 @@ +--- +- name: Modifier zabbix_agentd.conf et sudoer pour que zabbix puisse executer des scripts sur l'hote. + hosts: all + + tasks: + - name: Ajouter "AllowKey=system.run[*]" a /etc/zabbix/zabbix_agentd.conf + lineinfile: + path: /etc/zabbix/zabbix_agentd.conf + state: present + line: "AllowKey=system.run[*]" + regexp: "AllowKey=system.run[*]" + insertbefore: "### Option: LogRemoteCommands" + + - name: Commenter "DenyKey=system.run[*]" dans /etc/zabbix/zabbix_agentd.conf + lineinfile: + path: /etc/zabbix/zabbix_agentd.conf + state: present + firstmatch: yes + regexp: '^DenyKey=' + line: "#DenyKey=system.run[*]" + backrefs: yes + + - name: Make sure we have a 'zabbix' group + group: + name: zabbix + state: present + + - name: Allow 'zabbix' group to have passwordless sudo + lineinfile: + path: /etc/sudoers + state: present + regexp: '%zabbix' + insertafter: '^%sudo' + line: '%zabbix ALL=(ALL) NOPASSWD:{{ sudo_call_path }}' + validate: visudo -cf %s + + - name: Redemarrer le process "zabbix_agent" + systemd: + name: zabbix-agent + state: restarted