Mastering Ansible by James Freeman
Author:James Freeman
Language: eng
Format: epub
Tags: COM051360 - COMPUTERS / Programming Languages / Python, COM051440 - COMPUTERS / Software Development and Engineering / Tools, COM088010 - COMPUTERS / System Administration / Linux and UNIX Administration
Publisher: Packt Publishing
Published: 2019-03-22T12:28:51+00:00
tasks:
- name: create a directory
file:
path: /srv/whiskey/alpha
state: directory
- name: create another directory
file:
path: /srv/whiskey/beta
state: directory
When we run this, as expected, our two directories get created:
However, you can see this code is repetitive and inefficient. Instead, we could change it to something like this:
---
- name: looping demo
hosts: localhost
gather_facts: false
tasks:
- name: create a directory
file:
path: "{{ item }}"
state: directory
loop:
- /srv/whiskey/alpha
- /srv/whiskey/beta
Note the use of the special variable item, which is now used to define the path from the loop items at the bottom of the task. Now, when we run this code, the output looks somewhat different:
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Disaster & Recovery | Email Administration |
Linux & UNIX Administration | Storage & Retrieval |
Windows Administration |
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7781)
Grails in Action by Glen Smith Peter Ledbrook(7696)
Configuring Windows Server Hybrid Advanced Services Exam Ref AZ-801 by Chris Gill(6563)
Azure Containers Explained by Wesley Haakman & Richard Hooper(6551)
Running Windows Containers on AWS by Marcio Morales(6081)
Kotlin in Action by Dmitry Jemerov(5065)
Microsoft 365 Identity and Services Exam Guide MS-100 by Aaron Guilmette(4916)
Combating Crime on the Dark Web by Nearchos Nearchou(4498)
Management Strategies for the Cloud Revolution: How Cloud Computing Is Transforming Business and Why You Can't Afford to Be Left Behind by Charles Babcock(4414)
Microsoft Cybersecurity Architect Exam Ref SC-100 by Dwayne Natwick(4335)
The Ruby Workshop by Akshat Paul Peter Philips Dániel Szabó and Cheyne Wallace(4170)
The Age of Surveillance Capitalism by Shoshana Zuboff(3950)
Python for Security and Networking - Third Edition by José Manuel Ortega(3738)
Learn Windows PowerShell in a Month of Lunches by Don Jones(3508)
The Ultimate Docker Container Book by Schenker Gabriel N.;(3407)
Mastering Python for Networking and Security by José Manuel Ortega(3344)
Mastering Azure Security by Mustafa Toroman and Tom Janetscheck(3330)
Blockchain Basics by Daniel Drescher(3294)
Learn Wireshark by Lisa Bock(3260)
