November 2017
Intermediate to advanced
266 pages
5h 34m
English
Ansible code can be called using Python, using the Ansible API. Ansible has released version 2.0 of its API for better integration with programming languages. One important aspect to note is that Ansible has extended its capability to support development using Python, but it also suggests on its website that, based upon its own discretion, it can also stop supporting the API (creating or even bug fixing its current API version) framework.
Let us see an example of creating a play with the task of seeing the username from our earlier inventory of myrouters:
#call librariesimport jsonfrom collections import namedtuplefrom ansible.parsing.dataloader import DataLoaderfrom ansible.vars.manager import VariableManagerfrom ...
Read now
Unlock full access