Merge branch 'main' of github.com:alexpolo1/ansible
This commit is contained in:
2024-10-04 08:56:48 +02:00
104 changed files with 3415 additions and 3557 deletions

2
.github/ansible-code-bot.yml vendored Normal file
View File

@@ -0,0 +1,2 @@
schedule:
interval: weekly

View File

@@ -29,7 +29,7 @@
- name: Reboot the system if a reboot is required
ansible.builtin.reboot:
msg: "Reboot initiated by Ansible because updates require a restart"
msg: Reboot initiated by Ansible because updates require a restart
connect_timeout: 5
reboot_timeout: 600
pre_reboot_delay: 0

View File

@@ -6,129 +6,156 @@
- vault.yml
vars:
backup_dir: "/home"
nas_target_base: "/volume1/Backup"
backup_dir: /home
nas_target_base: /volume1/Backup
cron_time: "0 17 * * 0" # This represents every Sunday at 17:00
hostname: "{{ ansible_hostname }}"
cron_name: "Wake NAS and Backup to Synology NAS"
cron_name: Wake NAS and Backup to Synology NAS
ssh_key_paths:
- "/home/alex/.ssh/id_ed25519.pub"
- "/home/alex/.ssh/id_rsa.pub"
- "/home/alex/.ssh/id_ecdsa.pub"
- "/home/alex/.ssh/id_dsa.pub"
- /home/alex/.ssh/id_ed25519.pub
- /home/alex/.ssh/id_rsa.pub
- /home/alex/.ssh/id_ecdsa.pub
- /home/alex/.ssh/id_dsa.pub
tasks:
- name: Update apt cache
apt:
update_cache: yes
become: yes
become: true
ansible.builtin.apt:
update_cache: true
- name: Ensure rsync is installed
apt:
become: true
ansible.builtin.apt:
name: rsync
state: present
become: yes
- name: Ensure etherwake is installed
apt:
become: true
ansible.builtin.apt:
name: etherwake
state: present
become: yes
- name: Find network interface with 192.168.1.x IP address
shell: ip -o -4 addr list | grep '192.168.1.' | awk '{print $2}'
register: network_interface
ansible.builtin.shell: ip -o -4 addr list | grep '192.168.1.' | awk '{print $2}'
- name: Set network_interface fact
set_fact:
ansible.builtin.set_fact:
network_interface: "{{ network_interface.stdout }}"
- name: Find existing SSH public key
stat:
path: "{{ item }}"
with_items: "{{ ssh_key_paths }}"
register: ssh_key_check
ansible.builtin.stat:
path: "{{ item }}"
- name: Set SSH key path
set_fact:
ssh_key_path: "{{ ssh_key_check.results | selectattr('stat.exists', 'equalto', true) | map(attribute='item') | first }}"
when: ssh_key_check.results | selectattr('stat.exists', 'equalto', true) | length > 0
ansible.builtin.set_fact:
ssh_key_path: "{{ ssh_key_check.results | selectattr('stat.exists', 'equalto', true) | map(attribute='item') | first }}"
- name: Debug SSH key path
debug:
ansible.builtin.debug:
msg: "SSH key path: {{ ssh_key_path }}"
- name: Read the SSH public key
slurp:
src: "{{ ssh_key_path }}"
register: ssh_pub_key
when: ssh_key_path is defined
ansible.builtin.slurp:
src: "{{ ssh_key_path }}"
- name: Ensure .ssh directory exists on the NAS
<<<<<<< HEAD
command: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null alex@alex-ds414.localdomain 'mkdir -p ~/.ssh && chmod 700 ~/.ssh'"
ignore_errors: yes
- name: Add the SSH public key to the NAS authorized_keys
command: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null alex@alex-ds414.localdomain 'echo {{ ssh_pub_key.content | b64decode }} >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys'"
=======
ignore_errors: true
ansible.builtin.command: ssh alex@alex-ds414.localdomain 'mkdir -p ~/.ssh && chmod 700 ~/.ssh'
- name: Add the SSH public key to the NAS authorized_keys
>>>>>>> 1f4815ce65e05dc5fd5cb1a0b2d50a999060d539
when: ssh_key_path is defined
ansible.builtin.command: ssh alex@alex-ds414.localdomain 'echo {{ ssh_pub_key.content | b64decode }} >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys'
- name: Show debug info for rsync_user and rsync_password
debug:
ansible.builtin.debug:
msg: "rsync_user: {{ rsync_user }}, rsync_password: {{ rsync_password }}"
- name: Wake up the NAS
command: sudo etherwake -i {{ network_interface }} 00:11:32:43:FA:11
async: 0
poll: 0
become: yes
become: true
ansible.builtin.command: sudo etherwake -i {{ network_interface }} 00:11:32:43:FA:11
- name: Wait for 1 minute to allow NAS to start up initially
wait_for:
ansible.builtin.wait_for:
timeout: 60
- name: Check if NAS is reachable via SSH
<<<<<<< HEAD
command: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -o ConnectTimeout=5 alex@alex-ds414.localdomain echo 'SSH connection successful'"
=======
>>>>>>> 1f4815ce65e05dc5fd5cb1a0b2d50a999060d539
register: nas_ping_result
ignore_errors: yes
ignore_errors: true
ansible.builtin.command: ssh -o BatchMode=yes -o ConnectTimeout=5 alex@alex-ds414.localdomain echo 'SSH connection successful'
- name: Fail if the NAS is not reachable via SSH
fail:
msg: "NAS is not reachable via SSH. Exiting."
when: nas_ping_result.rc != 0
ansible.builtin.fail:
msg: NAS is not reachable via SSH. Exiting.
- name: Perform the test rsync
<<<<<<< HEAD
command: rsync -av --dry-run --delete --info=progress2 {{ backup_dir }}/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/
=======
>>>>>>> 1f4815ce65e05dc5fd5cb1a0b2d50a999060d539
register: rsync_test
ignore_errors: yes
ignore_errors: true
failed_when: rsync_test.rc not in [0, 23]
ansible.builtin.command: rsync -av --dry-run --delete {{ backup_dir }}/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/
- name: Fail if the rsync test fails for reasons other than permission issues
fail:
msg: "rsync test failed for reasons other than permission issues. Exiting."
when: rsync_test.rc not in [0, 23]
ansible.builtin.fail:
msg: rsync test failed for reasons other than permission issues. Exiting.
- name: Perform the backup using rsync
<<<<<<< HEAD
command: rsync -av --delete --info=progress2 {{ backup_dir }}/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/
=======
>>>>>>> 1f4815ce65e05dc5fd5cb1a0b2d50a999060d539
when: rsync_test.rc in [0, 23]
ignore_errors: yes
ignore_errors: true
failed_when: rsync_test.rc not in [0, 23]
ansible.builtin.command: rsync -av --delete {{ backup_dir }}/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/
- name: Check if cron job exists
cron:
register: cron_present
ignore_errors: true
ansible.builtin.cron:
name: "{{ cron_name }}"
state: present
register: cron_present
ignore_errors: yes
- name: Add cron job for backup if not present
cron:
when: rsync_test.rc in [0, 23] and (cron_present is not defined or cron_present is failed)
become: true
ansible.builtin.cron:
name: "{{ cron_name }}"
minute: "{{ cron_time.split()[0] }}"
hour: "{{ cron_time.split()[1] }}"
day: "{{ cron_time.split()[2] }}"
month: "{{ cron_time.split()[3] }}"
weekday: "{{ cron_time.split()[4] }}"
<<<<<<< HEAD
job: "sudo etherwake -i {{ network_interface }} 00:11:32:43:FA:11 && sleep 300 && rsync -av --info=progress2 --delete /home/ alex@alex-ds414.localdomain:{{ nas_target_base }}/{{ hostname }}/"
when: rsync_test.rc == 0 and (cron_present is not defined or cron_present is failed)
become: yes
=======
job: sudo etherwake -i {{ network_interface }} 00:11:32:43:FA:11 && sleep 300 && rsync -av --delete /home/ alex@alex-ds414.localdomain:{{ nas_target_base
}}/{{ hostname }}/
>>>>>>> 1f4815ce65e05dc5fd5cb1a0b2d50a999060d539

View File

@@ -3,14 +3,14 @@
hosts: proxmox.localdomain
gather_facts: false
vars:
api_host: "192.168.1.162"
api_user: "root@pam"
api_token_id: "mytoki"
api_token_secret: "ea5114f5-ed39-4277-ac09-a32984be5bc9"
proxmox_node: "pve" # Add your Proxmox node name here
api_host: 192.168.1.162
api_user: root@pam
api_token_id: mytoki
api_token_secret: ea5114f5-ed39-4277-ac09-a32984be5bc9
proxmox_node: pve # Add your Proxmox node name here
vars_prompt:
- name: new_vm_name
prompt: "Enter the name for the new VM"
prompt: Enter the name for the new VM
private: false
tasks:
- name: List all VMs and templates
@@ -43,11 +43,11 @@
api_token_id: "{{ api_token_id }}"
api_token_secret: "{{ api_token_secret }}"
api_host: "{{ api_host }}"
clone: "ubu-srv01"
clone: ubu-srv01
name: "{{ new_vm_name }}"
node: "{{ proxmox_node }}"
storage: "local"
format: "qcow2"
storage: local
format: qcow2
full: true
timeout: 240
validate_certs: false

View File

@@ -19,4 +19,3 @@
name: "{{ vm_name }}"
node: "{{ node_name }}"
state: present

View File

@@ -83,7 +83,7 @@
port: "{{ zabbix_port | default(10050) }}"
tls_connect: 2
tls_accept: 2
tls_psk_identity: "PSK-{{ inventory_hostname }}"
tls_psk_identity: PSK-{{ inventory_hostname }}
tls_psk: "{{ zabbix_psk.stdout }}"
proxy: "{{ zabbix_proxy | default(omit) }}"
become: false

View File

@@ -6,30 +6,30 @@ all:
ubu.localdomain:
ansible_host: 192.168.1.23
ansible_user: alex
ansible_ssh_pass: "Aase#1234!"
ansible_become_pass: "Aase#1234!"
zabbix_host_groups: "Linux servers"
zabbix_link_template: "Template OS Linux"
zabbix_agent_psk: "1d3b2f634a975a68df1ac903daa4d10d5b00a3d95c33463cffb402f5e39be75f"
ansible_ssh_pass: Aase#1234!
ansible_become_pass: Aase#1234!
zabbix_host_groups: Linux servers
zabbix_link_template: Template OS Linux
zabbix_agent_psk: 1d3b2f634a975a68df1ac903daa4d10d5b00a3d95c33463cffb402f5e39be75f
raspii.localdomain:
ansible_host: 192.168.1.24
ansible_user: alex
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_pass: "Aase#1234!"
ansible_become_pass: "Aase#1234!"
zabbix_host_groups: "Linux servers"
zabbix_link_template: "Template OS Linux"
zabbix_agent_psk: "1d3b2f634a975a68df1ac903daa4d10d5b00a3d95c33463cffb402f5e39be75f"
ansible_ssh_pass: Aase#1234!
ansible_become_pass: Aase#1234!
zabbix_host_groups: Linux servers
zabbix_link_template: Template OS Linux
zabbix_agent_psk: 1d3b2f634a975a68df1ac903daa4d10d5b00a3d95c33463cffb402f5e39be75f
proxmox.localdomain:
ansible_host: 192.168.1.162
ansible_user: root
ansible_password: Aase#1234!
ansible_python_interpreter: /root/proxmoxer_env/bin/python
ansible_ssh_pass: "Aase#1234!"
ansible_become_pass: "Aase#1234!"
zabbix_host_groups: "Linux servers"
zabbix_link_template: "Template OS Linux"
zabbix_agent_psk: "1d3b2f634a975a68df1ac903daa4d10d5b00a3d95c33463cffb402f5e39be75f"
ansible_ssh_pass: Aase#1234!
ansible_become_pass: Aase#1234!
zabbix_host_groups: Linux servers
zabbix_link_template: Template OS Linux
zabbix_agent_psk: 1d3b2f634a975a68df1ac903daa4d10d5b00a3d95c33463cffb402f5e39be75f
vars:
proxmox_host: 192.168.1.162
proxmox_user: root@pam
@@ -44,11 +44,11 @@ all:
ansible_host: 192.168.1.144
ansible_user: alex
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_pass: "Aase#1234!"
ansible_become_pass: "Aase#1234!"
zabbix_host_groups: "Linux servers"
zabbix_link_template: "Template OS Linux"
zabbix_agent_psk: "1d3b2f634a975a68df1ac903daa4d10d5b00a3d95c33463cffb402f5e39be75f"
ansible_ssh_pass: Aase#1234!
ansible_become_pass: Aase#1234!
zabbix_host_groups: Linux servers
zabbix_link_template: Template OS Linux
zabbix_agent_psk: 1d3b2f634a975a68df1ac903daa4d10d5b00a3d95c33463cffb402f5e39be75f
alex-ds414.localdomain:
ansible_host: 192.168.1.113
ansible_user: alexadmin
@@ -78,3 +78,8 @@ all:
zabbix_host_groups: "Linux servers"
zabbix_link_template: "Template OS Linux"
zabbix_agent_psk: "1d3b2f634a975a68df1ac903daa4d10d5b00a3d95c33463cffb402f5e39be75f"
ansible_ssh_pass: Aase#1234!
ansible_become_pass: Aase#1234!
zabbix_host_groups: Linux servers
zabbix_link_template: Template OS Linux
zabbix_agent_psk: 1d3b2f634a975a68df1ac903daa4d10d5b00a3d95c33463cffb402f5e39be75f1f4815ce65e05dc5fd5cb1a0b2d50a999060d539

View File

@@ -3,15 +3,14 @@
hosts: homeserver.localdomain
gather_facts: false
vars:
winrmadmin_username: "ansible_user"
winrmadmin_password: "YourStrongPasswordHere"
winrmadmin_username: ansible_user
winrmadmin_password: YourStrongPasswordHere
tasks:
- name: Get WinRM credentials from Ansible Vault
ansible.builtin.include_vars:
file: /home/alex/git/ansible/credentials.yml
name: vault_vars
- name: List Hyper-V virtual machines
ansible.windows.win_shell: |
Get-VM | Select-Object Name, State, MemoryAssigned, ProcessorCount, Uptime

View File

@@ -1,13 +1,13 @@
---
- name: List VMs, Templates, and ISOs on Proxmox
hosts: proxmox.localdomain
gather_facts: no
gather_facts: false
vars:
api_host: "192.168.1.162"
api_user: "root@pam"
api_token_id: "mytoki"
api_token_secret: "ea5114f5-ed39-4277-ac09-a32984be5bc9"
proxmox_node: "pve" # Add your Proxmox node name here
api_host: 192.168.1.162
api_user: root@pam
api_token_id: mytoki
api_token_secret: ea5114f5-ed39-4277-ac09-a32984be5bc9
proxmox_node: pve # Add your Proxmox node name here
tasks:
- name: List all VMs
community.general.proxmox_vm_info:
@@ -15,11 +15,11 @@
api_user: "{{ api_user }}"
api_token_id: "{{ api_token_id }}"
api_token_secret: "{{ api_token_secret }}"
validate_certs: no
validate_certs: false
register: vms_info
- name: Print VM info
debug:
ansible.builtin.debug:
var: vms_info
- name: List all nodes
@@ -28,11 +28,11 @@
api_user: "{{ api_user }}"
api_token_id: "{{ api_token_id }}"
api_token_secret: "{{ api_token_secret }}"
validate_certs: no
validate_certs: false
register: nodes_info
- name: Print node info
debug:
ansible.builtin.debug:
var: nodes_info
- name: List all ISOs
@@ -41,12 +41,11 @@
api_user: "{{ api_user }}"
api_token_id: "{{ api_token_id }}"
api_token_secret: "{{ api_token_secret }}"
validate_certs: no
validate_certs: false
storage: local
node: "{{ proxmox_node }}"
register: isos_info
- name: Print ISO info
debug:
ansible.builtin.debug:
var: isos_info

View File

@@ -3,9 +3,9 @@ plugin: ansible.builtin.nmap
strict: false
address: 192.168.1.0/24
exclude: 192.168.1.1
command: '-sn'
command: -sn
keyed_groups:
- prefix: 'os_'
key: 'os'
- prefix: os_
key: os
compose:
ansible_host: ip

View File

@@ -18,7 +18,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
- name: Slack
hosts: localhost
gather_facts: false

View File

@@ -18,7 +18,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
- name: Slack
hosts: localhost
gather_facts: false

View File

@@ -22,8 +22,8 @@
- krb5-libs
- krb5-workstation
state: latest
update_cache: yes
become: yes
update_cache: true
become: true
when: (ansible_os_family == "RedHat" or ansible_os_family == "CentOS") and ansible_distribution_version is version('8.0', 'lt')
- name: Install Required Packages - Debian/Ubuntu
@@ -34,12 +34,12 @@
- libkrb5-dev
- krb5-user
state: latest
update_cache: yes
become: yes
update_cache: true
become: true
when: ansible_os_family == "Debian"
- name: Install python winrm wrapper
pip:
name: "pywinrm[kerberos]"
name: pywinrm[kerberos]
state: latest
become: yes
become: true

View File

@@ -3,7 +3,7 @@
hosts: localhost
gather_facts: false
vars:
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\u0000',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\0',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
tasks:
- name: Send notification message via Slack
community.general.slack:
@@ -20,7 +20,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
## AxInstall
- name: Install AXInstall
hosts: AOS
@@ -31,7 +30,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
## Post-installs
# AXInstall example
@@ -45,7 +43,6 @@
# rescue:
# - include: tasks/task-failed-slack.yaml
# BOInstall example
#- name: Install PI46849_MDL
@@ -57,16 +54,12 @@
# rescue:
# - include: tasks/task-failed-slack.yaml
# PI46867_CWS_DBIFS_APP
# - Skip because default BOInstall is BOInstall_120.81.2.0_120-81-2-0.exe
# PI46869_APP_API_BorisWeb
# - Skip because default BOInstall is BOInstall_120.81.2.0_120-81-2-0.exe
- name: Slack
hosts: localhost
gather_facts: false

View File

@@ -3,7 +3,7 @@
hosts: localhost
gather_facts: false
vars:
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\u0000',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\0',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
tasks:
- name: Send notification message via Slack
community.general.slack:

View File

@@ -3,7 +3,7 @@
hosts: localhost
gather_facts: false
vars:
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\u0000',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\0',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
tasks:
- name: Send notification message via Slack
community.general.slack:

View File

@@ -3,7 +3,7 @@
hosts: localhost
gather_facts: false
vars:
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\u0000',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\0',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
tasks:
- name: Send notification message via Slack
community.general.slack:
@@ -20,7 +20,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
## AxInstall install-axinstall
- name: Install AXInstall
hosts: AOS

View File

@@ -3,7 +3,7 @@
hosts: localhost
gather_facts: false
vars:
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\u0000',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\0',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
tasks:
- name: Send notification message via Slack
community.general.slack:
@@ -20,7 +20,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
## AxInstall
- name: Install AXInstall
hosts: AOS
@@ -31,7 +30,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
## Post-installs
# AXInstall example
@@ -45,7 +43,6 @@
# rescue:
# - include: tasks/task-failed-slack.yaml
# BOInstall example
#- name: Install PI46849_MDL
@@ -57,16 +54,12 @@
# rescue:
# - include: tasks/task-failed-slack.yaml
# PI46867_CWS_DBIFS_APP
# - Skip because default BOInstall is BOInstall_120.81.2.0_120-81-2-0.exe
# PI46869_APP_API_BorisWeb
# - Skip because default BOInstall is BOInstall_120.81.2.0_120-81-2-0.exe
- name: Slack
hosts: localhost
gather_facts: false

View File

@@ -18,7 +18,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
- name: Slack
hosts: localhost
gather_facts: false

View File

@@ -18,7 +18,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
- name: Slack
hosts: localhost
gather_facts: false

View File

@@ -3,7 +3,7 @@
hosts: localhost
gather_facts: false
vars:
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\u0000',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\0',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
tasks:
- name: Send notification message via Slack
community.general.slack:
@@ -20,7 +20,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
## AxInstall
- name: Install AXInstall
hosts: AOS
@@ -31,7 +30,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
## Post-installs
# AXInstall example
@@ -45,7 +43,6 @@
# rescue:
# - include: tasks/task-failed-slack.yaml
# BOInstall example
#- name: Install PI46849_MDL
@@ -57,16 +54,12 @@
# rescue:
# - include: tasks/task-failed-slack.yaml
# PI46867_CWS_DBIFS_APP
# - Skip because default BOInstall is BOInstall_120.81.2.0_120-81-2-0.exe
# PI46869_APP_API_BorisWeb
# - Skip because default BOInstall is BOInstall_120.81.2.0_120-81-2-0.exe
- name: Slack
hosts: localhost
gather_facts: false

View File

@@ -3,7 +3,7 @@
hosts: localhost
gather_facts: false
vars:
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\u0000',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\0',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
tasks:
- name: Send notification message via Slack
community.general.slack:

View File

@@ -3,14 +3,13 @@
hosts: localhost
gather_facts: false
vars:
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\u0000',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\0',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
tasks:
- name: Send notification message via Slack
community.general.slack:
token: "{{ slack_token }}"
msg: Starting {{ playbook_file }}
- name: Start AOS
hosts: AOS
gather_facts: false
@@ -20,8 +19,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
- name: Start BCM_CLUSTER
hosts: BCM_CLUSTER
gather_facts: false
@@ -31,8 +28,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
- name: Start APP
hosts: APP
gather_facts: false
@@ -42,7 +37,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
- name: Start DPS, FAS, MDL, SPS, TCS
hosts: DPS, FAS, MDL, SPS, TCS
gather_facts: false
@@ -52,7 +46,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
- name: Start WEB, API
hosts: WEB, API
gather_facts: false
@@ -62,7 +55,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
#- name: Start Nagios
# hosts: SMC
# tasks:
@@ -72,8 +64,6 @@
# - name: podman start n2a
# command: podman start n2a
- name: Slack
hosts: localhost
gather_facts: false

View File

@@ -3,7 +3,7 @@
hosts: localhost
gather_facts: false
vars:
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\u0000',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\0',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
tasks:
- name: Send notification message via Slack
community.general.slack:
@@ -19,7 +19,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
- name: Slack
hosts: localhost
gather_facts: false

View File

@@ -3,7 +3,7 @@
hosts: localhost
gather_facts: false
vars:
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\u0000',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\0',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
tasks:
- name: Send notification message via Slack
community.general.slack:
@@ -28,7 +28,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
- name: Stop DPS, FAS, MDL, SPS, TCS
hosts: DPS, FAS, MDL, SPS, TCS
gather_facts: false
@@ -39,7 +38,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
- name: Stop APP
hosts: APP
gather_facts: false
@@ -49,7 +47,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
- name: Stop BCM_CLUSTER
hosts: BCM_CLUSTER
gather_facts: false
@@ -60,7 +57,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
- name: Stop AOS
hosts: AOS
gather_facts: false
@@ -70,7 +66,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
- name: Slack
hosts: localhost
gather_facts: false

View File

@@ -7,7 +7,7 @@
- name: Running Clean-up Scripts
ansible.windows.win_powershell:
script: |
script: |-
#Script to Clean-up
#Creating Directory

View File

@@ -9,10 +9,10 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI43972_CWS/_BaseLayout.cshtml
dest: D:\IFSBOSystem\WebSite\CWS\Views\Shared\
backup: yes
backup: true
- name: Copy Renew.cshtml
win_copy:
src: ~/ansible/install/PostInstalls/PI43972_CWS/Renew.cshtml
dest: D:\IFSBOSystem\WebSite\CWS\Views\SeasonPass\
backup: yes
backup: true

View File

@@ -9,10 +9,10 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI43976_CWSWEB/ui-icons_444444_256x240.png
dest: D:\IFSBOSystem\WebSite\CWS\App_Themes\CWS\images\
backup: yes
backup: true
- name: Copy ui-icons_555555_256x240.png
win_copy:
src: ~/ansible/install/PostInstalls/PI43976_CWSWEB/ui-icons_555555_256x240.png
dest: D:\IFSBOSystem\WebSite\CWS\App_Themes\CWS\images\
backup: yes
backup: true

View File

@@ -9,4 +9,4 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI43980_DBIFS_CWSWEB/CWSDictionary.xml
dest: D:\IFSBOSystem\WebSite\CWS\App_Data\CWSDictionary.xml
backup: yes
backup: true

View File

@@ -9,4 +9,4 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI43981_CWSWEB/CWS.dll
dest: D:\IFSBOSystem\WebSite\CWS\bin\
backup: yes
backup: true

View File

@@ -9,4 +9,4 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI46769_CWSWEB/CWS.dll
dest: D:\IFSBOSystem\WebSite\CWS\bin\
backup: yes
backup: true

View File

@@ -9,4 +9,4 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI46777_CWSWEB/MyInformation.cshtml
dest: D:\IFSBOSystem\WebSite\CWS\Views\CustomerManagement\MyInformation.cshtml
backup: yes
backup: true

View File

@@ -9,13 +9,13 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI46792_MDL/DCP_CMNDeEncoder_P.dll
dest: D:\IFSBOSystem\bin\DCP_CMNDeEncoder_P.dll
backup: yes
backup: true
- name: Copy Register_DCP_CMNDeEncoder_P_FileProcessor.bat
win_copy:
src: ~/ansible/install/PostInstalls/PI46792_MDL/Register_DCP_CMNDeEncoder_P_FileProcessor.bat
dest: D:\IFSBOSystem\bin\Register_DCP_CMNDeEncoder_P_FileProcessor.bat
backup: yes
backup: true
- name: Register dll
win_command: D:\IFSBOSystem\bin\Register_DCP_CMNDeEncoder_P_FileProcessor.bat

View File

@@ -8,4 +8,4 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI46810_DBIFS_CWSWEB_BORISWEB/BorisDictionary.xml
dest: D:\IFSBOSystem\WebSite\Boris\App_Data\BorisDictionary.xml
backup: yes
backup: true

View File

@@ -8,4 +8,4 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI46810_DBIFS_CWSWEB_BORISWEB/CWSDictionary.xml
dest: D:\IFSBOSystem\WebSite\CWS\App_Data\CWSDictionary.xml
backup: yes
backup: true

View File

@@ -7,12 +7,10 @@
- name: Start Ax service
ansible.windows.win_service:
name: "aos60$01"
name: aos60$01
state: started
start_mode: auto
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -45,6 +43,6 @@
- name: Stop Ax service
ansible.windows.win_service:
name: "aos60$01"
name: aos60$01
state: stopped
start_mode: auto

View File

@@ -5,15 +5,13 @@
token: "{{ slack_token }}"
msg: Installing PI46849_MDL on {{ inventory_hostname }}
- name: Stop Housekeeping Agent
ansible.windows.win_service:
name: IFSHouseKeepingAgent
state: stopped
- name: Copy IFS.HouseKeeping.Agent.exe
win_copy:
src: ~/ansible/install/PostInstalls/PI46849_MDL/IFS.HouseKeeping.Agent.exe
dest: D:\IFSBOSystem\bin\IFS.HouseKeeping.Agent.exe
backup: yes
backup: true

View File

@@ -9,10 +9,10 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI43972_CWS/_BaseLayout.cshtml
dest: D:\IFSBOSystem\WebSite\CWS\Views\Shared\
backup: yes
backup: true
- name: Copy Renew.cshtml
win_copy:
src: ~/ansible/install/PostInstalls/PI43972_CWS/Renew.cshtml
dest: D:\IFSBOSystem\WebSite\CWS\Views\SeasonPass\
backup: yes
backup: true

View File

@@ -9,10 +9,10 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI43976_CWSWEB/ui-icons_444444_256x240.png
dest: D:\IFSBOSystem\WebSite\CWS\App_Themes\CWS\images\
backup: yes
backup: true
- name: Copy ui-icons_555555_256x240.png
win_copy:
src: ~/ansible/install/PostInstalls/PI43976_CWSWEB/ui-icons_555555_256x240.png
dest: D:\IFSBOSystem\WebSite\CWS\App_Themes\CWS\images\
backup: yes
backup: true

View File

@@ -9,4 +9,4 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI43980_DBIFS_CWSWEB/CWSDictionary.xml
dest: D:\IFSBOSystem\WebSite\CWS\App_Data\CWSDictionary.xml
backup: yes
backup: true

View File

@@ -9,4 +9,4 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI43981_CWSWEB/CWS.dll
dest: D:\IFSBOSystem\WebSite\CWS\bin\
backup: yes
backup: true

View File

@@ -9,4 +9,4 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI46769_CWSWEB/CWS.dll
dest: D:\IFSBOSystem\WebSite\CWS\bin\
backup: yes
backup: true

View File

@@ -9,4 +9,4 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI46777_CWSWEB/MyInformation.cshtml
dest: D:\IFSBOSystem\WebSite\CWS\Views\CustomerManagement\MyInformation.cshtml
backup: yes
backup: true

View File

@@ -9,13 +9,13 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI46792_MDL/DCP_CMNDeEncoder_P.dll
dest: D:\IFSBOSystem\bin\DCP_CMNDeEncoder_P.dll
backup: yes
backup: true
- name: Copy Register_DCP_CMNDeEncoder_P_FileProcessor.bat
win_copy:
src: ~/ansible/install/PostInstalls/PI46792_MDL/Register_DCP_CMNDeEncoder_P_FileProcessor.bat
dest: D:\IFSBOSystem\bin\Register_DCP_CMNDeEncoder_P_FileProcessor.bat
backup: yes
backup: true
- name: Register dll
win_command: D:\IFSBOSystem\bin\Register_DCP_CMNDeEncoder_P_FileProcessor.bat

View File

@@ -8,4 +8,4 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI46810_DBIFS_CWSWEB_BORISWEB/BorisDictionary.xml
dest: D:\IFSBOSystem\WebSite\Boris\App_Data\BorisDictionary.xml
backup: yes
backup: true

View File

@@ -8,4 +8,4 @@
win_copy:
src: ~/ansible/install/PostInstalls/PI46810_DBIFS_CWSWEB_BORISWEB/CWSDictionary.xml
dest: D:\IFSBOSystem\WebSite\CWS\App_Data\CWSDictionary.xml
backup: yes
backup: true

View File

@@ -7,12 +7,10 @@
- name: Start Ax service
ansible.windows.win_service:
name: "aos60$01"
name: aos60$01
state: started
start_mode: auto
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -45,6 +43,6 @@
- name: Stop Ax service
ansible.windows.win_service:
name: "aos60$01"
name: aos60$01
state: stopped
start_mode: auto

View File

@@ -5,15 +5,13 @@
token: "{{ slack_token }}"
msg: Installing PI46849_MDL on {{ inventory_hostname }}
- name: Stop Housekeeping Agent
ansible.windows.win_service:
name: IFSHouseKeepingAgent
state: stopped
- name: Copy IFS.HouseKeeping.Agent.exe
win_copy:
src: ~/ansible/install/PostInstalls/PI46849_MDL/IFS.HouseKeeping.Agent.exe
dest: D:\IFSBOSystem\bin\IFS.HouseKeeping.Agent.exe
backup: yes
backup: true

View File

@@ -20,9 +20,6 @@
src: ~/ansible/install/config/v12.0/rejtesta.local/{{ inventory_hostname.split('.')[0]|upper }}/
dest: D:\AXInstall\Config
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -37,8 +34,6 @@
Get-Process AXInstall | Wait-Process
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -55,8 +50,6 @@
}
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -65,10 +58,6 @@
- name: Reboot
win_reboot:
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:

View File

@@ -20,9 +20,6 @@
src: ~/ansible/install/config/v12.0/rejtestc.local/{{ inventory_hostname.split('.')[0]|upper }}/
dest: D:\AXInstall\Config
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -37,8 +34,6 @@
Get-Process AXInstall | Wait-Process
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -55,8 +50,6 @@
}
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -65,10 +58,6 @@
- name: Reboot
win_reboot:
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:

View File

@@ -20,9 +20,6 @@
src: ~/ansible/install/config/v12.0/rejtesta.local/{{ inventory_hostname.split('.')[0]|upper }}/
dest: D:\BOInstall\Config
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -37,8 +34,6 @@
Get-Process BOInstall | Wait-Process
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -55,7 +50,6 @@
}
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -73,7 +67,6 @@
D:\BOInstall\fixlog4net.ps1
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:

View File

@@ -20,9 +20,6 @@
src: ~/ansible/install/config/v12.0/rejtestc.local/{{ inventory_hostname.split('.')[0]|upper }}/
dest: D:\BOInstall\Config
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -37,8 +34,6 @@
Get-Process BOInstall | Wait-Process
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -55,7 +50,6 @@
}
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -73,7 +67,6 @@
D:\BOInstall\fixlog4net.ps1
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:

View File

@@ -20,9 +20,6 @@
src: ~/ansible/install/config/v12.0/rejtesta.local/{{ inventory_hostname.split('.')[0]|upper }}/
dest: D:\BOInstall\Config
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -37,8 +34,6 @@
Get-Process BOInstall | Wait-Process
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -55,7 +50,6 @@
}
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -73,7 +67,6 @@
D:\BOInstall\fixlog4net.ps1
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:

View File

@@ -1,3 +1,4 @@
---
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -29,8 +30,6 @@
- name: Start Ax service
ansible.windows.win_service:
name: "aos60$01"
name: aos60$01
state: stopped
start_mode: auto

View File

@@ -1,3 +1,4 @@
---
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -6,18 +7,16 @@
- name: Start Ax service
ansible.windows.win_service:
name: "aos60$01"
name: aos60$01
state: started
start_mode: auto
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
token: "{{ slack_token }}"
msg: Starting CIL compile on {{ inventory_hostname }}
#- name: Compile CIL using Invoke-AxaptaServerCmd
# ansible.windows.win_shell: |
# $null = . 'D:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities\Microsoft.Dynamics.ManagementUtilities.ps1'
@@ -63,7 +62,6 @@
tags:
- ax_compile_cil
- name: Send CIL compilation result notification via Slack
delegate_to: localhost
community.general.slack:
@@ -74,9 +72,6 @@
tags:
- ax_compile_cil
#- name: Show CIL compilation result
# ansible.builtin.debug:
# var: cil_compile_output.stdout_lines
@@ -107,6 +102,6 @@
- name: Stop Ax service
ansible.windows.win_service:
name: "aos60$01"
name: aos60$01
state: stopped
start_mode: auto

View File

@@ -1,3 +1,4 @@
---
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -22,7 +23,6 @@
msg: "Deployed TravelCard Services on {{ inventory_hostname }} : {{ 'Success' if script_result else 'Failed' }}"
when: script_result is defined and script_result.stdout is defined
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -31,7 +31,7 @@
- name: Start Ax service
ansible.windows.win_service:
name: "aos60$01"
name: aos60$01
state: restarted
start_mode: manual
@@ -43,7 +43,7 @@
- name: Start Ax service
ansible.windows.win_service:
name: "aos60$01"
name: aos60$01
state: started
start_mode: manual
@@ -55,8 +55,6 @@
- name: Start Ax service
ansible.windows.win_service:
name: "aos60$01"
name: aos60$01
state: stopped
start_mode: auto

View File

@@ -7,7 +7,7 @@
- name: Start Ax service
ansible.windows.win_service:
name: "aos60$01"
name: aos60$01
state: started
start_mode: manual
@@ -60,7 +60,6 @@
token: "{{ slack_token }}"
msg: "no install mode set on {{ inventory_hostname }} : {{output.output}}"
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -90,6 +89,6 @@
- name: Stop Ax service
ansible.windows.win_service:
name: "aos60$01"
name: aos60$01
state: stopped
start_mode: manual

View File

@@ -1,3 +1,4 @@
---
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:

View File

@@ -7,7 +7,7 @@
- name: Start Ax service
ansible.windows.win_service:
name: "aos60$01"
name: aos60$01
state: started
start_mode: manual
@@ -30,7 +30,8 @@
register: result
- name: Verify synchronization
win_shell: Get-EventLog -LogName Application -Source "Dynamics Server 01" -After (Get-Date).Date | Where-Object {$_.Source -eq "Dynamics Server 01" -and $_.Message -like "*Sync finished*"}
win_shell: Get-EventLog -LogName Application -Source "Dynamics Server 01" -After (Get-Date).Date | Where-Object {$_.Source -eq "Dynamics Server 01" -and $_.Message
-like "*Sync finished*"}
register: event_log_result
- name: Show verification result
@@ -41,14 +42,14 @@
delegate_to: localhost
community.general.slack:
token: "{{ slack_token }}"
msg: "{% if event_log_result.stdout_lines %}:white_check_mark: Database synchronization on {{ inventory_hostname }} completed successfully.{% else %}:x: Database synchronization on {{ inventory_hostname }} failed with exit code {{ event_log_result.rc }}.{% endif %}"
msg: "{% if event_log_result.stdout_lines %}:white_check_mark: Database synchronization on {{ inventory_hostname }} completed successfully.{% else %}:x: Database
synchronization on {{ inventory_hostname }} failed with exit code {{ event_log_result.rc }}.{% endif %}"
- name: Send xpp_compile start message via Slack
delegate_to: localhost
community.general.slack:
token: "{{ slack_token }}"
msg: "Starting xppcompileall on {{ inventory_hostname }}"
msg: Starting xppcompileall on {{ inventory_hostname }}
- name: xppcompileall AX
ansible.windows.win_shell: |
@@ -88,8 +89,6 @@
}}
when: xppcompile_result is defined
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -98,6 +97,6 @@
- name: Stop Ax service
ansible.windows.win_service:
name: "aos60$01"
name: aos60$01
state: stopped
start_mode: manual

View File

@@ -20,9 +20,6 @@
src: ~/ansible/install/config/{{ configVersion }}/{{ configName }}/{{ inventory_hostname.split('.')[0]|upper }}/
dest: D:\AXInstall\Config
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -37,8 +34,6 @@
Get-Process AXInstall | Wait-Process
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -55,8 +50,6 @@
}
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -65,10 +58,6 @@
- name: Reboot
win_reboot:
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:

View File

@@ -20,9 +20,6 @@
src: ~/ansible/install/config/{{ configVersion }}/{{ configName }}/{{ inventory_hostname.split('.')[0]|upper }}/
dest: D:\BOInstall\Config
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -37,8 +34,6 @@
Get-Process BOInstall | Wait-Process
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -71,8 +66,6 @@
# script: |
# D:\BOInstall\fixlog4net.ps1
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:

View File

@@ -15,7 +15,6 @@
src: ~/ansible/install/{{Note_install}}
dest: D:\software\{{Note_install}}
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -46,7 +45,6 @@
}
###name: Clean up
### ansible.windows.win_file:
### path: D:\software\{{Note_install}}

View File

@@ -20,9 +20,6 @@
src: ~/ansible/install/config/v12.0/rejtesta.local/{{ inventory_hostname.split('.')[0]|upper }}/
dest: D:\AXInstall\Config
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -37,8 +34,6 @@
Get-Process AXInstall | Wait-Process
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -55,8 +50,6 @@
}
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -65,10 +58,6 @@
- name: Reboot
win_reboot:
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:

View File

@@ -20,9 +20,6 @@
src: ~/ansible/install/config/v12.0/rejtestc.local/{{ inventory_hostname.split('.')[0]|upper }}/
dest: D:\AXInstall\Config
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -37,8 +34,6 @@
Get-Process AXInstall | Wait-Process
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -55,8 +50,6 @@
}
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -65,10 +58,6 @@
- name: Reboot
win_reboot:
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:

View File

@@ -20,9 +20,6 @@
src: ~/ansible/install/config/v12.0/rejtesta.local/{{ inventory_hostname.split('.')[0]|upper }}/
dest: D:\BOInstall\Config
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -37,8 +34,6 @@
Get-Process BOInstall | Wait-Process
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -55,7 +50,6 @@
}
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -73,7 +67,6 @@
D:\BOInstall\fixlog4net.ps1
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:

View File

@@ -20,9 +20,6 @@
src: ~/ansible/install/config/v12.0/rejtestc.local/{{ inventory_hostname.split('.')[0]|upper }}/
dest: D:\BOInstall\Config
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -37,8 +34,6 @@
Get-Process BOInstall | Wait-Process
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -55,7 +50,6 @@
}
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -73,7 +67,6 @@
D:\BOInstall\fixlog4net.ps1
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:

View File

@@ -20,9 +20,6 @@
src: ~/ansible/install/config/v12.0/rejtesta.local/{{ inventory_hostname.split('.')[0]|upper }}/
dest: D:\BOInstall\Config
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -37,8 +34,6 @@
Get-Process BOInstall | Wait-Process
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -55,7 +50,6 @@
}
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:
@@ -73,7 +67,6 @@
D:\BOInstall\fixlog4net.ps1
- name: Send notification message via Slack
delegate_to: localhost
community.general.slack:

View File

@@ -7,6 +7,6 @@
- name: Starting Dynamics Ax service
ansible.windows.win_service:
name: "aos60$01"
name: aos60$01
state: started
start_mode: auto

View File

@@ -7,7 +7,7 @@
- name: IFSBO-Start
ansible.windows.win_powershell:
script: |
script: |-
# start agent service
Get-Service -DisplayName 'IFS HouseKeeping Agent' | Start-Service
# connect to agent

View File

@@ -7,6 +7,6 @@
- name: Stop Dynamics Ax service
ansible.windows.win_service:
name: "aos60$01"
name: aos60$01
state: stopped
start_mode: manual

View File

@@ -34,4 +34,3 @@
}
# Shutdown agent
$proxy.ShutdownAndQuit($forceQuit, $true)

View File

@@ -12,5 +12,5 @@
- name: Run fixlog4net
ansible.windows.win_powershell:
script: |
script: |-
D:\BOInstall\fixlog4net.ps1

View File

@@ -1,7 +1,7 @@
---
- name: Deleting contents of XppiL folder
ansible.windows.win_powershell:
script: |
script: |-
$path = 'D:\Program Files\Microsoft Dynamics AX\60\Server\TravelCardDynamicsAX\bin\XppIL'
Get-Item -Path "$path\*" | Remove-Item -Force -Recurse
$items = Get-ChildItem -Recurse -Path $path

View File

@@ -31,9 +31,7 @@
token: "{{ slack_token }}"
msg: Cleanup IFSBOSystem on {{ inventory_hostname }}
- name: Cleanup IFSBOSystem folder
win_file:
path: D:\IFSBOSystem
state: absent

View File

@@ -3,7 +3,7 @@
hosts: localhost
gather_facts: false
vars:
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\u0000',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\0',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
tasks:
- name: Send notification message via Slack
community.general.slack:
@@ -20,7 +20,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
## AxInstall
- name: Install AXInstall
hosts: AOS
@@ -31,7 +30,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
#- name: AXInstall Post-Installation tasks
# hosts: AOS_POM
# gather_facts: false
@@ -41,7 +39,6 @@
# rescue:
# - include: tasks/task-failed-slack.yaml
## Post-installs
#- name: Install PI46810 - CWS
# hosts: WEB_CWS

View File

@@ -3,7 +3,7 @@
hosts: localhost
gather_facts: false
vars:
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\u0000',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\0',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
tasks:
- name: Send notification message via Slack
community.general.slack:

View File

@@ -7,4 +7,3 @@
- include: tasks/test-log4net.yaml
rescue:
- include: tasks/task-failed-slack.yaml

View File

@@ -13,4 +13,3 @@
register: winping
- debug: var=winping

View File

@@ -3,7 +3,7 @@
hosts: localhost
gather_facts: false
vars:
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\u0000',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\0',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
tasks:
- name: Send notification message via Slack
community.general.slack:
@@ -24,7 +24,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
## AxInstall
- name: Uninstall AXInstall
hosts: AOS

View File

@@ -3,7 +3,7 @@
hosts: localhost
gather_facts: false
vars:
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\u0000',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\0',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
tasks:
- name: Send notification message via Slack
community.general.slack:
@@ -24,7 +24,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
## BOInstall
- name: Uninstall BOInstall
hosts: BOInstall
@@ -34,4 +33,3 @@
- include: tasks/uninstall-boinstall.yaml
rescue:
- include: tasks/task-failed-slack.yaml

View File

@@ -3,7 +3,7 @@
hosts: localhost
gather_facts: false
vars:
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\u0000',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\0',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}"
tasks:
- name: Send notification message via Slack
community.general.slack:
@@ -24,7 +24,6 @@
rescue:
- include: tasks/task-failed-slack.yaml
## BOInstall
- name: Uninstall BOInstall
hosts: BOInstall

View File

@@ -1,17 +1,17 @@
---
- name: Remove VM on Proxmox
hosts: proxmox.localdomain
gather_facts: no
gather_facts: false
vars:
api_host: "192.168.1.162"
api_user: "root@pam"
api_token_id: "mytoki"
api_token_secret: "ea5114f5-ed39-4277-ac09-a32984be5bc9"
proxmox_node: "pve"
api_host: 192.168.1.162
api_user: root@pam
api_token_id: mytoki
api_token_secret: ea5114f5-ed39-4277-ac09-a32984be5bc9
proxmox_node: pve
vars_prompt:
- name: vm_name_to_remove
prompt: "Enter the name of the VM to remove"
private: no
prompt: Enter the name of the VM to remove
private: false
tasks:
- name: List all VMs and templates
community.general.proxmox_vm_info:
@@ -19,19 +19,19 @@
api_user: "{{ api_user }}"
api_token_id: "{{ api_token_id }}"
api_token_secret: "{{ api_token_secret }}"
validate_certs: no
validate_certs: false
register: vms_info
- name: Find VMID based on VM name
set_fact:
vmid_to_remove: "{{ item.vmid }}"
loop: "{{ vms_info.proxmox_vms }}"
when: item.name == vm_name_to_remove
ansible.builtin.set_fact:
vmid_to_remove: "{{ item.vmid }}"
- name: Debug VMID to remove
debug:
msg: "VMID to remove: {{ vmid_to_remove }}"
when: vmid_to_remove is defined
ansible.builtin.debug:
msg: "VMID to remove: {{ vmid_to_remove }}"
- name: Remove the VM
community.general.proxmox_kvm:
@@ -45,7 +45,6 @@
when: vmid_to_remove is defined
- name: Print message if VM was not found
debug:
msg: "VM {{ vm_name_to_remove }} not found."
when: vmid_to_remove is not defined
ansible.builtin.debug:
msg: VM {{ vm_name_to_remove }} not found.

View File

@@ -1,3 +1,4 @@
---
galaxy_info:
author: name1
description: superorle
@@ -40,12 +41,12 @@ galaxy_info:
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,

View File

@@ -1,3 +1,4 @@
---
galaxy_info:
author: your name
description: your role description
@@ -40,12 +41,12 @@ galaxy_info:
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,

View File

@@ -18,5 +18,5 @@
register: clients
- name: Display clients details
debug:
ansible.builtin.debug:
var: clients.results

View File

@@ -1,6 +1,7 @@
zabbix_server: "192.168.1.24"
zabbix_server_url: "http://192.168.1.24/api_jsonrpc.php"
zabbix_login_user: "Admin"
zabbix_login_password: "zabbix"
---
zabbix_server: 192.168.1.24
zabbix_server_url: http://192.168.1.24/api_jsonrpc.php
zabbix_login_user: Admin
zabbix_login_password: zabbix
zabbix_host_group: "2" # Change this to the correct group ID for your setup
zabbix_template_id: "10001" # Change this to the correct template ID for your setup

View File

@@ -1,3 +1,4 @@
---
galaxy_info:
author: your name
description: your role description
@@ -22,12 +23,12 @@ galaxy_info:
# min_ansible_container_version:
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,

View File

@@ -1,65 +1,68 @@
---
- name: Update apt cache
apt:
update_cache: true
become: true
ansible.builtin.apt:
update_cache: true
- name: Install Zabbix agent
apt:
become: true
ansible.builtin.apt:
name: zabbix-agent
state: present
become: true
- name: Ensure Zabbix agent is running and enabled
service:
become: true
ansible.builtin.service:
name: zabbix-agent
state: started
enabled: true
become: true
- name: Configure Zabbix agent
template:
become: true
ansible.builtin.template:
src: zabbix_agentd.conf.j2
dest: /etc/zabbix/zabbix_agentd.conf
become: true
- name: Generate PSK for Zabbix agent
shell: echo -n "4e616d656461706c617965722072616e646f6d6b65792067656e657261746564" > /etc/zabbix/zabbix_agentd.psk
become: true
ansible.builtin.shell: echo -n "4e616d656461706c617965722072616e646f6d6b65792067656e657261746564" > /etc/zabbix/zabbix_agentd.psk
- name: Restart Zabbix agent
service:
become: true
ansible.builtin.service:
name: zabbix-agent
state: restarted
become: true
- name: Authenticate with Zabbix API
uri:
url: "http://192.168.1.24/api_jsonrpc.php"
method: POST
body_format: json
headers:
Content-Type: "application/json"
body:
jsonrpc: "2.0"
method: "user.login"
params:
username: "Admin"
password: "zabbix"
id: 1
register: auth_response
delegate_to: localhost
- name: Create or update a host in Zabbix
uri:
url: "http://192.168.1.24/api_jsonrpc.php"
ansible.builtin.uri:
url: http://192.168.1.24/api_jsonrpc.php
method: POST
body_format: json
headers:
Content-Type: "application/json"
Content-Type: application/json
body:
jsonrpc: "2.0"
method: "host.create"
method: user.login
params:
username: Admin
password: zabbix
id: 1
- name: Create or update a host in Zabbix
register: zabbix_host_response
delegate_to: localhost
when: auth_response.json.result is defined
ansible.builtin.uri:
url: http://192.168.1.24/api_jsonrpc.php
method: POST
body_format: json
headers:
Content-Type: application/json
body:
jsonrpc: "2.0"
method: host.create
params:
host: "{{ inventory_hostname }}"
interfaces:
@@ -70,21 +73,18 @@
dns: ""
port: "10050"
groups:
- groupid: "2" # Group ID for "Linux servers"
- groupid: "2"
templates:
- templateid: "10001" # Template ID for "Template OS Linux"
- templateid: "10001"
tls_connect: 2
tls_accept: 2
tls_psk_identity: "PSK-{{ inventory_hostname }}"
tls_psk: "4e616d656461706c617965722072616e646f6d6b65792067656e657261746564" # Example PSK
tls_psk_identity: PSK-{{ inventory_hostname }}
tls_psk: 4e616d656461706c617965722072616e646f6d6b65792067656e657261746564
auth: "{{ auth_response.json.result }}"
id: 1
register: zabbix_host_response
delegate_to: localhost
when: auth_response.json.result is defined
- name: Check Zabbix agent status
service:
become: true
ansible.builtin.service:
name: zabbix-agent
state: started
become: true

View File

@@ -1,17 +1,17 @@
---
- name: Retrieve and display UniFi port forwarding rules
hosts: localhost
gather_facts: no
gather_facts: false
tasks:
- name: Get port forwarding rules
unifi_portforward_module:
controller_url: "https://192.168.1.237:8443"
username: "alex_mormor@hotmail.com"
password: "aaseiswild123"
site_id: "default"
controller_url: https://192.168.1.237:8443
username: alex_mormor@hotmail.com
password: aaseiswild123
site_id: default
mfa_token: "{{ lookup('password', 'Enter your MFA token: ') }}"
register: result
- name: Display port forwarding rules
debug:
ansible.builtin.debug:
var: result.portforwarding_rules

View File

@@ -1,3 +1,4 @@
---
#playbook
- name: Playbook useing the role shutdown-role on windows servers
hosts: windows

View File

@@ -1,11 +1,11 @@
---
- name: Test Zabbix API connection
hosts: localhost
gather_facts: no
gather_facts: false
tasks:
- name: Set API token
ansible.builtin.set_fact:
ansible_zabbix_auth_key: "6965e0d3bf4416a15ce750e7dba47933d3dfc988d99d866291b0f2d55845bb05"
ansible_zabbix_auth_key: 6965e0d3bf4416a15ce750e7dba47933d3dfc988d99d866291b0f2d55845bb05
- name: Configure HTTPAPI connection
ansible.builtin.set_fact:
@@ -14,10 +14,10 @@
- name: Test Zabbix API connection
community.zabbix.zabbix_api_info:
http_login_user: "Admin"
http_login_password: "zabbix"
http_login_user: Admin
http_login_password: zabbix
register: result
- name: Debug Zabbix API version
debug:
ansible.builtin.debug:
var: result

View File

@@ -1,17 +1,17 @@
---
- name: Retrieve and display UniFi port forwarding rules
hosts: localhost
gather_facts: no
gather_facts: false
tasks:
- name: Get port forwarding rules
unifi_portforward_module:
controller_url: "https://192.168.1.237:8443"
username: "alex_mormor@hotmail.com"
password: "aaseiswild123"
site_id: "default"
controller_url: https://192.168.1.237:8443
username: alex_mormor@hotmail.com
password: aaseiswild123
site_id: default
mfa_token: "{{ lookup('password', 'Enter your MFA token: ') }}"
register: result
- name: Display port forwarding rules
debug:
ansible.builtin.debug:
var: result.portforwarding_rules

View File

@@ -10,7 +10,7 @@
- name: Print version for network devices
when: ansible_network_os is defined
debug:
ansible.builtin.debug:
msg: "{{ result.stdout }}"
- name: Gather facts for regular servers

View File

@@ -1,39 +1,39 @@
---
- name: Update and Shutdown Ubuntu Server
- name: Update and Shutdown Ubuntu Server
hosts: ubuntu_server
become: yes
gather_facts: no
become: true
gather_facts: false
tasks:
- name: Wake up the server using Wake-on-LAN
local_action:
module: wakeonlan
mac: "MAC_ADDRESS_HERE"
broadcast: "BROADCAST_ADDRESS_HERE"
module: community.general.wakeonlan
mac: MAC_ADDRESS_HERE
broadcast: BROADCAST_ADDRESS_HERE
delegate_to: localhost
- name: Wait for the server to come online
wait_for:
ansible.builtin.wait_for:
host: "{{ inventory_hostname }}"
port: 22
state: started
timeout: 300
- name: Update all packages to the latest version
apt:
update_cache: yes
ansible.builtin.apt:
update_cache: true
upgrade: dist
autoremove: yes
autoclean: yes
autoremove: true
autoclean: true
- name: Reboot the server
reboot:
ansible.builtin.reboot:
- name: Check if updates were successful
command: apt list --upgradable
register: upgradable_packages
changed_when: false
failed_when: upgradable_packages.stdout != ""
ansible.builtin.command: apt list --upgradable
- name: Shut down the server
command: shutdown now
ansible.builtin.command: shutdown now

View File

@@ -1,6 +1,6 @@
---
- name: Ensure Zabbix agent is installed and configured
hosts: all
gather_facts: yes
gather_facts: true
roles:
- zabbix_agent

View File

@@ -1,39 +1,41 @@
---
- name: Create or update a Zabbix host
hosts: all
gather_facts: yes
gather_facts: true
tasks:
- name: Authenticate with Zabbix API
uri:
url: "http://192.168.1.24/api_jsonrpc.php"
register: auth_response
delegate_to: localhost
ansible.builtin.uri:
url: http://192.168.1.24/api_jsonrpc.php
method: POST
body_format: json
headers:
Content-Type: "application/json"
Content-Type: application/json
body:
jsonrpc: "2.0"
method: "user.login"
method: user.login
params:
username: "Admin"
password: "zabbix"
username: Admin
password: zabbix
id: 1
register: auth_response
delegate_to: localhost
- name: Debug auth response
debug:
ansible.builtin.debug:
var: auth_response
- name: Create or update a host in Zabbix
uri:
url: "http://192.168.1.24/api_jsonrpc.php"
delegate_to: localhost
when: auth_response.json.result is defined
ansible.builtin.uri:
url: http://192.168.1.24/api_jsonrpc.php
method: POST
body_format: json
headers:
Content-Type: "application/json"
Content-Type: application/json
body:
jsonrpc: "2.0"
method: "host.create"
method: host.create
params:
host: "{{ inventory_hostname }}"
interfaces:
@@ -44,14 +46,12 @@
dns: ""
port: "10050"
groups:
- groupid: "2" # Group ID for "Linux servers"
- groupid: "2"
templates:
- templateid: "10001" # Template ID for "Template OS Linux"
- templateid: "10001"
tls_connect: 2
tls_accept: 2
tls_psk_identity: "PSK-{{ inventory_hostname }}"
tls_psk: "4e616d656461706c617965722072616e646f6d6b65792067656e657261746564" # Example PSK
tls_psk_identity: PSK-{{ inventory_hostname }}
tls_psk: 4e616d656461706c617965722072616e646f6d6b65792067656e657261746564
auth: "{{ auth_response.json.result }}"
id: 1
delegate_to: localhost
when: auth_response.json.result is defined

View File

@@ -4,20 +4,20 @@
become: true
tasks:
- name: Open firewall port 10050 for Zabbix agent (Debian)
ansible.builtin.ufw:
when: ansible_os_family == "Debian"
community.general.ufw:
rule: allow
port: 10050
proto: tcp
when: ansible_os_family == "Debian"
- name: Open firewall port 10050 for Zabbix agent (RedHat)
firewalld:
when: ansible_os_family == "RedHat"
ansible.posix.firewalld:
service: zabbix-agent
port: 10050/tcp
permanent: true
state: enabled
immediate: true
when: ansible_os_family == "RedHat"
- name: Restart firewall to apply changes (Debian)
ansible.builtin.service: