--- - name: BIG-IP SETUP hosts: lb connection: local gather_facts: false vars: - pool_name: "test_http_pool" - vip_name: "test_vip_name" tasks: - name: Setup provider set_fact: provider: server: "{{private_ip}}" user: "{{ansible_user}}" password: "{{ansible_ssh_pass}}" server_port: "8443" validate_certs: "no" - name: SETUP AND GRACEFUL ROLLBACK BIG-IP CONFIGURATION block: - name: CREATE NODES bigip_node: provider: "{{provider}}" host: "{{hostvars[item].ansible_host}}" name: "{{hostvars[item].inventory_hostname}}" loop: "{{ groups['webservers'] }}" - name: CREATE POOL bigip_pool: provider: "{{provider}}" name: "{{pool_name}}" lb_method: "round-robin" monitors: "/Common/http" monitor_type: "and_list" - name: ADD POOL MEMBERS bigip_pool_member: provider: "{{provider}}" state: "present" name: "{{hostvars[item].inventory_hostname}}" host: "{{hostvars[item].ansible_host}}" port: "80" pool: "{{pool_name}}" loop: "{{ groups['webservers'] }}" - name: ADD VIRTUAL SERVER bigip_virtual_server: provider: "{{provider}}" name: "{{vip_name}}" destination: "{{private_ip}}" port: "443" enabled_vlans: "all" all_profiles: ['http','clientssl','oneconnect'] pool: "{{pool_name}}" snat: "Automap1" rescue: - name: DELETE VIRTUAL SERVER bigip_virtual_server: provider: "{{provider}}" name: "{{vip_name}}" state: absent - name: DELETE POOL bigip_pool: provider: "{{provider}}" name: "{{pool_name}}" state: absent - name: DELETE NODES bigip_node: provider: "{{provider}}" name: "{{hostvars[item].inventory_hostname}}" state: absent loop: "{{ groups['webservers'] }}" always: - name: SAVE RUNNING CONFIGURATION bigip_config: provider: "{{provider}}" save: yes