Tag: Ansible

Problem The other day one of my playbooks reported an issue with connecting to one of the switches. What seemed odd is that the this playbook ran against this box without any problems ten minutes earlier. I double checked my password and all the permissions, all seemed to be in order. Just as a test, I tried to run this playbook for other devices, worked like a charm. It was time to turn the debug and full verbosity (-vvvv), on. Here's what I found in the logs: 2017-10-08 11:24:01,589 p=30940 u=przemek | PLAYBOOK: arista_test.yml...

Continue reading »

Knowing date and timestamp comes handy in many tasks involving automation. We can use these for logging purposes, include in the names of output files, and directories. We can even decide if the task should execute at all based on the current timestamp.   Ansible "ansible_date_time" fact There are a number of ways in which we can retrieve the values for the current date and timestamp. For example, we can take advantage of the facts that Ansible gathers at the beginning of each playbook. Ansible will record the current date and time in the variable "ansible_...

Continue reading »

In this blog post I'll show how to add items to lists and dictionaries, when using loops, and across tasks. Normally when trying to add a new item to the variable, while in the loop, or between tasks, Ansible will ovewrite the values, keeping the result of the last iteration. For example, let's see what will be the result of running the following playbook: --- - name: Append to list hosts: localhost vars: cisco: - CiscoRouter01 - CiscoRouter02 - CiscoRouter03 - CiscoSwitch01 arista: - AristaSwitch01 - AristaSwitch02 - AristaSwitch03 tasks: - name: Add Cisco and Airsta devices to the list...

Continue reading »