Forum Discussion
Run Ansible Playbook based on the Redundancy State.
We have two nodes in our PRODUCTION environment that are setup as active-standby pair. Generally i have to login, see the status and run the playbook manually on the device that is currently active.
But is there a way to make Ansible to figure our what is the active node and run Playbook on the Active node automatically?
Thanks in advance!
- smandru_360193
Nimbostratus
Any help on this would be appreciated! Thanks!
- Vijay_E
Cirrus
Do you not use a floating IP address to log into the devices ? The floating IP is associated with the active F5 and it is easier to know for sure that you are accessing the active F5. You can also try to execute a "show" command to identify the active F5, if you want to pursue that route.
- Aaron_Booker
Employee
You may have already figured it out based on previous comments, but for posterity, below is an example of using the failover_state bigip fact as a condition for performing a task which is hopefully what you were after. The bigip_node task in this playbook contains a when statement so it only runs when the value of the failover_state fact is HA_STATE_ACTIVE; therefore, the task runs on the active device and not the standby. As you probably know if you create sync'able objects on all devices in the DG with a playbook you'll encounter a change conflict between the DG members. This playbook avoids that.
Update: Removing my example and instead pointing to:
K10531487: Running Ansible tasks on the active BIG-IP in a device group
Which AskF5 has published based on this Q&A. They've done this for other Q&As on DC as well.
This article contains more detailed instructions for creating this playbook and you can leave feedback at the bottom of the page.
- e0013192
Altostratus
I get an error when running this playbook. Error is "msg": "module (bigip_facts) is missing interpreter line". I'm using the bigip_facts.py from the f5-ansible repo on github
- Aaron_Booker
Employee
That error does not appear to be specific to F5 Ansible modules. Looks like an error that occurs when Ansible can't find the module due to a naming conflict. The following issues offer clues:
Does running the playbook with high verbosity, the -vvvv flag, give you more details about the error?
- e0013192
Altostratus
I see what your saying but I don't understand why is doing this. It's looking for the module in "Using module file /media/sf_f5_ansible_modules/f5_playbooks/bigip_facts.yml" but this is not the module file and the directory for the module in my ansible.cfg is /media/sf_f5_ansible_modules. Can you explained why this might be happening?
- adb_11155Historic F5 Account
You may have already figured it out based on previous comments, but for posterity, below is an example of using the failover_state bigip fact as a condition for performing a task which is hopefully what you were after. The bigip_node task in this playbook contains a when statement so it only runs when the value of the failover_state fact is HA_STATE_ACTIVE; therefore, the task runs on the active device and not the standby. As you probably know if you create sync'able objects on all devices in the DG with a playbook you'll encounter a change conflict between the DG members. This playbook avoids that.
Update: Removing my example and instead pointing to:
K10531487: Running Ansible tasks on the active BIG-IP in a device group
Which AskF5 has published based on this Q&A. They've done this for other Q&As on DC as well.
This article contains more detailed instructions for creating this playbook and you can leave feedback at the bottom of the page.
- e0013192
Altostratus
I get an error when running this playbook. Error is "msg": "module (bigip_facts) is missing interpreter line". I'm using the bigip_facts.py from the f5-ansible repo on github
- adb_11155Historic F5 Account
That error does not appear to be specific to F5 Ansible modules. Looks like an error that occurs when Ansible can't find the module due to a naming conflict. The following issues offer clues:
Does running the playbook with high verbosity, the -vvvv flag, give you more details about the error?
- e0013192
Altostratus
I see what your saying but I don't understand why is doing this. It's looking for the module in "Using module file /media/sf_f5_ansible_modules/f5_playbooks/bigip_facts.yml" but this is not the module file and the directory for the module in my ansible.cfg is /media/sf_f5_ansible_modules. Can you explained why this might be happening?
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com