AnsiblePilot — Master Ansible Automation

AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,400 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 8 Ansible books published by Apress and Leanpub including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

Retrieve ASM Policy Facts from the F5 BIG-IP Platform Network Infrastructure

By Luca Berton · Published 2024-01-01 · Category: installation

How to retrieve the ASM Policy Facts from the F5 BIG-IP Platform Network Infrastructure using Ansible Network f5networks.f5_modules.

Retrieve ASM Policy Facts from the F5 BIG-IP Platform Network Infrastructure

Retrieve ASM Policy Facts from the F5 Network Infrastructure

Businesses nowadays are using DevOps and automation to speed up application development and eliminate IT bottlenecks. Network automation is the next frontier. We can use Ansible to automate application delivery services like identity and access management, web application security, and TCP optimization. Combining together with the F5 services, we can automate and orchestrate using Ansible through a series of integrations with the F5 BIG-IP platform API modules. Ansible F5 modules enable the most common use cases and follow best practices while providing an agentless solution that makes use of the native APIs of BIG-IP, improving configuration and automation speed and consistency.

See also: Automate Dell EMC DNOS 10 Backups with Ansible Playbook

Links

bigip_device_info moduleF5Networks.F5_Modules

Code

The "F5Networks.F5_Modules” Ansible collection interacts with F5 infrastructure. Install in our system using the ansible-galaxy tool:

ansible-galaxy collection install f5networks.f5_modules

We are going to use the following F5 modules:

f5networks.f5_modules.bigip_device_info module – Collect information from F5 BIG-IP devices

The following “f5.yml” Ansible Playbook retrieves the ASM Policy Facts Full from the F5 infrastructure and prints them on the screen:

---
- name: Retrieve ASM Policy Facts Full
  hosts: all
  connection: local
  collections:
    - f5networks.f5_modules
  gather_facts: true
  vars:
    provider:
      server: f5.example.com
      user: admin
      password: mypassword
      validate_certs: false
      server_port: 443 
 
  tasks:
    - name: Export policy in XML format
      bigip_device_info:
        gather_subset:
          - asm-policies
        provider: "{{ provider }}"
      register: device_facts
      delegate_to: localhost
 
    - name:  Print ASM Policy Facts Full
      ansible.builtin.debug: 
        var : device_facts | json_query ("asm_policies [*].name")
        
    - name: print list    
      ansible.builtin.debug:
        var : policies_list

See also: Backup Dell EMC DNOS 6 Configs with Ansible Playbook

Conclusion

Now you know how to Retrieve ASM Policy Facts from the F5 Network Infrastructure with Ansible.

Related Articles

installing roles from Ansible Galaxy

Category: installation

Browse all Ansible tutorials · AnsiblePilot Home