loop

Ansible: implementing a looping block using include_tasks

Ansible blocks provide a convenient way to logically group tasks.  So it is unfortunate that native Ansible syntax does not allow looping to be combined with a block.  Consider the simple conditional block below controlled by a variable ‘do_block_logic’: – name: simple block with conditional block: – name: simple block task1 debug: msg=”hello” – name: Ansible: implementing a looping block using include_tasks

Bash: Associative array initialization and usage

Just as in other programming languages, associative arrays in Bash are useful for search, set management, and keying into a list of values.  The label may be different, but whether called “map”, “dictionary”, or “associative array”, the same concepts apply. In its simplest form, here is an initialization and then loop through the key/value pairs. Bash: Associative array initialization and usage

Linux: Mounting a loopback ext4/xfs filesystem to isolate or enforce storage limits

The physical partitions and filesystem formats on your host are configured for your main workload, but if you want an application to use a specific filesystem (xfs, ext4, zfs) and size capacity without reconfiguration at the physical level then you can consider a loopback image. For example, if we create a 100Mb disk file named Linux: Mounting a loopback ext4/xfs filesystem to isolate or enforce storage limits

SaltStack: Setting a jinja2 variable from an inner block scope

When using jinja2 for SaltStack formulas you may be surprised to find that your global scoped variables do not have ability to be modified inside a loop.  Although this is counter intuitive given the scope behavior of most scripting languages it is unfortunately the case that a jinja2 globally scoped variable cannot be modified from SaltStack: Setting a jinja2 variable from an inner block scope