====== Ansible validated playbooks ======
===== Download IBM AIX efix (ifix) =====
Download IBM AIX efix based on dates for 2 last years, and also flrt script and security apar.
$ /ansible/download/download_efix.yml
---
- name: "AIX sync all ifixes on webserver"
hosts: localhost
gather_facts: false
vars:
ifix_path: "/ansible/efix"
ifix_url: "https://aix.software.ibm.com/aix/ifixes/security"
apar_csv_url: "https://esupport.ibm.com/customercare/flrt/doc?page=aparCSV"
apar_csv_filename: "apar.csv"
flrtvc_url: "https://esupport.ibm.com/customercare/sas/f/flrt3/FLRTVC-latest.zip"
flrtvc_filename: "FLRTVC-latest.zip"
debug: false
sync_ifix: true
sync_apar: true
sync_flrtvc: true
index_file: "/ansible/efix/index.html"
years_to_filter:
- "{{ lookup('pipe', 'date +\"%Y-\"') }}"
- "{{ lookup('pipe', 'date -d \"1 year ago\" +\"%Y-\"') }}"
environment:
https_proxy: "http://http-proxyxxxx:8080"
tasks:
- name: "Create ifix_path {{ ifix_path }} if not exists"
ansible.builtin.file:
path: "{{ ifix_path }}"
state: directory
mode: '0755'
- name: "Synchronizing {{ ifix_path }}/{{ apar_csv_filename }} from {{ apar_csv_url }}"
#"Synchronizing {{ ifix_path }} from {{ apr_csv_url }}"
#Synchronizing {{ ifix_path }}/{{ apar_csv_filename }} from {{ apr_csv_url }}
ansible.builtin.get_url:
url: "{{ apar_csv_url }}"
dest: "{{ ifix_path }}/{{ apar_csv_filename }}" # Path where you want to download the files
force: yes
backup: no
when: sync_apar
- name: Print apard
ansible.builtin.debug:
var: apard
when:
- sync_apar
- debug
- name: "Synchronizing {{ ifix_path }}/FLRTVC-latest.zip from {{ flrtvc_url }}"
ansible.builtin.get_url:
url: "{{ flrtvc_url }}"
dest: "{{ ifix_path }}/{{ flrtvc_filename }}" # Path where you want to download the files
force: yes
backup: no
when: sync_flrtvc
- name: Print flrtvcd
ansible.builtin.debug:
var: flrtvcd
when:
- sync_flrtvc
- debug
- name: Delete content & directory
ansible.builtin.file:
state: absent
path: "{{ index_file }}"
- name: "Synchronizing {{ index_file }} from {{ ifix_url }}"
ansible.builtin.get_url:
url: "{{ ifix_url }}"
dest: "{{ index_file }}" # Path where you want to download the files
force: yes
backup: yes
when: sync_ifix
- name: Print ifixd
ansible.builtin.debug:
var: ifixd
when:
- sync_ifix
- debug
- name: Read the HTML file
ansible.builtin.slurp:
src: "{{ index_file }}"
register: html_content
- name: Decode HTML content
set_fact:
decoded_html: "{{ html_content.content | b64decode }}"
- name: Loop through each year and find files
set_fact:
files_filtered_per_year: "{{ files_filtered_per_year | default({}) | combine({ item: (decoded_html | regex_findall('href=\"([^\"]+)\".*' + item)) }) }}"
loop: "{{ years_to_filter }}"
loop_control:
loop_var: item
- name: Show files modified in each year
debug:
var: files_filtered_per_year
- name: Download files modified in the specified years
ansible.builtin.get_url:
url: "{{ ifix_url }}/{{ item }}"
dest: "{{ ifix_path }}/{{ item }}" # Path where you want to download the files
force: yes
backup: no
loop: "{{ files_filtered_per_year[years_to_filter[0]] + files_filtered_per_year[years_to_filter[1]] }}" # Dynamically use the years_to_filter list
when: files_filtered_per_year[years_to_filter[0]] is defined or files_filtered_per_year[years_to_filter[1]] is defined
- name: "Recursive fix permissions on ifix_path {{ ifix_path }}"
ansible.builtin.file:
path: "{{ ifix_path }}"
mode: "u=rwX,g=rwX,o=rX"
recurse: true