List methods

Most of the methods Ansible provides relating to lists perform modifications on the list itself. However, there are two list methods that are useful when working with lists, especially when loops become involved. These two functions are index and count, and their functionality is described as follows:

  • index: Returns the first index position of a provided value
  • count: Counts the items in the list

These can be incredibly useful when iterating through a list in a loop, as it allows positional logic to be performed and appropriate actions to be taken, given our position in the list as we work through it. This is common in other programming languages, and fortunately, Ansible also provides this.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.190.159.10