-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathf5-cleanup.yml
56 lines (53 loc) · 1.56 KB
/
f5-cleanup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
- name: BIG-IP cleanup
hosts: "{{ target_hosts | default('f5') }}"
gather_facts: True
vars:
provider:
server: "{{ inventory_hostname }}"
user: admin
password: admin
validate_certs: no
tasks:
- name: Get Software Volume Information
f5networks.f5_modules.bigip_device_info:
gather_subset:
- software-volumes
- software-images
- software-hotfixes
provider: "{{ provider }}"
register: sv
delegate_to: localhost
- name: Output all software images
ansible.builtin.debug:
var: sv.software_images
- name: Example of getting index and name
ansible.builtin.debug:
msg: "{{ index }} - {{ item.name }}"
loop: "{{ sv.software_images|flatten(levels=1) }}"
loop_control:
index_var: index
- name: Remove images
f5networks.f5_modules.bigip_software_image:
image: "{{ item.name }}"
state: absent
provider: "{{ provider }}"
loop: "{{ sv.software_images|flatten(levels=1) }}"
loop_control:
index_var: index
#- name: Get non active software volumes
# ansible.builtin.debug:
# msg: "{{ index }} - {{ item.name }}"
# loop: "{{ sv.software_volumes|flatten(levels=1) }}"
# loop_control:
# index_var: index
# when:
# item.active == "no"
#- name: run show version on remote devices
# bigip_command:
# commands: list /sys software volume
# provider: "{{ provider }}"
# register: cmd_result
# delegate_to: localhost
#- name: with_indexed_items -> loop
# ansible.builtin.debug:
# msg: "{{ cmd_result }}"