Forum Discussion
Andy_McGrath
Feb 05, 2019Cumulonimbus
Give the following, or something similar a try. This uses a
provider
variable for connection details.
I remember I had an issue with one BIGIP module that didn't work correctly with the
provider
so is you get an error with one might need to change it back but found got less issues with the BIGIP modules that work with the provider
.
Also another question question is what verion of the F5 Python SDK are you running?
- name: "Syncing F5 Active config to group"
hosts: "drhaf5"
serial: 1
vars_files:
- "vars/main.yml"
- "vars/vault.yml"
vars:
f5Provider:
server: "{{ inventory_hostname }}"
server_port: 443
user: admin
password: "{{adminpass}}"
validate_certs: no
transport: rest
gather_facts: "no"
roles:
- "f5syncactive"
tasks:
- name: "Get bigip facts"
bigip_facts:
provider: "{{f5Provider}}"
include:
- "device"
- "system_info"
check_mode: no
delegate_to: "localhost"
- name: "Display bigip facts {{inventory_hostname}}"
debug:
msg:
- "Hostname: {{ system_info.system_information.host_name }}"
- "Status: {{ device['/Common/' + system_info.system_information.host_name].failover_state }}"
- name: "Create pool"
bigip_pool:
provider: "{{f5Provider}}"
lb_method: "round-robin"
monitors: http
name: "pool1"
notify:
- "Save the running configuration to disk"
- "Sync configuration from device to group"
delegate_to: "localhost"
when: device['/Common/' + system_info.system_information.host_name].failover_state == "HA_STATE_ACTIVE"
handlers:
- name: "Save the running {{inventory_hostname}} configuration to disk"
bigip_config:
save: "yes"
provider: "{{f5Provider}}"
delegate_to: localhost
- name: "Handler Sync configuration from {{inventory_hostname}} to group"
bigip_configsync_action:
device_group: "sync-failover-group"
sync_device_to_group: "yes"
provider: "{{f5Provider}}"
delegate_to: localhost