Dig deeper into Ansible and F5 integration
Perfect - thanks very much!!!
So after editing /etc/ansible/hosts to include at the bottom:
[bigip] 10.XX.XX.XX [bigip:vars] username=admin password=admin
The second block of text is saved as var-onboard-network_file.yml, and the 3rd block of text is saved in the same folder as the var-onboard-network_file.yml file and is called whatever_you_like.yml
The playbook is then called by running: $ ansible-playbook whatever_you_like.yml
For other beginners, see: http://f5-ansible.readthedocs.io/en/devel/modules/list_of_all_modules.html for additional examples
So if we look at the bigip_selfip ansible command: http://f5-ansible.readthedocs.io/en/devel/modules/bigip_selfip_module.html
For this command there are some settings in the variables file, and some information in the playbook. The playbopok calls the items from the variables file.
bigip_selfip command in the playbook:
- name: Configure SELF-IPs on the BIG-IP
bigip_selfip:
server: "{{ inventory_hostname }}"
user: "{{ username }}"
password: "{{ password }}"
validate_certs: False
name: "{{ item.name }}" name item selected from variable file
address: "{{ item.address }}" address item selected from variable file
netmask: "{{ item.netmask }}" netmask item selected from variable file
vlan: "{{ item.vlan }}" vlan item selected from variable file
allow_service: "{{item.allow_service}}" allow_service item selected from variable file
with_items: "{{ selfip_information }}" variable file items heading selection = selfip_information
delegate_to: localhost
items in the variables file:
selfip_information: - name: 'External-SelfIP' address: '10.128.10.101' netmask: '255.255.255.0' vlan: 'External' allow_service: 'none' - name: 'Internal-SelfIP' address: '10.128.20.101' netmask: '255.255.255.0' vlan: 'Internal' allow_service: 'none' - name: 'HA-SelfIP' address: '1.1.1.1' netmask: '255.255.255.252' vlan: 'HA' allow_service: 'default'
So the ansible command bigip_selfip has multiple switches such as name, address, netmask. The values for these are called from the variables file by the playbook by using {{ item.XXX }} as the value. The values are under selfip_information heading in the var file. So taking a selction from the above config
Playbook: name: "{{ item.name }}" address: "{{ item.address }}" with_items: "{{ selfip_information }}"
Var file items: selfip_information: - name: 'External-SelfIP' equal to {{ item.name }} when called by the playbook address: '10.128.10.101' equal to {{ item.address }} when called by the playbook
And for some other of payal's awesome example playbooks and their associated var files
You also need an updated ansible and f5 and other python modules installed for it to work
-
Ubuntu - Install ansible $ sudo apt-get update $ sudo apt-get install software-properties-common $ sudo apt-add-repository ppa:ansible/ansible $ sudo apt-get update $ sudo apt-get install ansible
-
Install pip $ sudo apt-get install pip then install the below $ pip install f5-sdk bigsuds netaddr deepdiff