Slide 1

Slide 1 text

@KeithResar

Slide 2

Slide 2 text

@KeithResar Keith [email protected] @KeithResar

Slide 3

Slide 3 text

● ● ●

Slide 4

Slide 4 text

● ● ● ● ● ● ● ●

Slide 5

Slide 5 text

# this is a 'play' include - include: listofplays - name: another play hosts: all tasks: - debug: msg=hello # this is a 'task' include - include: stuff.yml

Slide 6

Slide 6 text

- include_playbook: webservers.yml # or - import_playbook: databases.yml --- tasks: - include_tasks: common_tasks.yml # or - import_tasks: common_tasks.yml foo=bar

Slide 7

Slide 7 text

- hosts: all # Specify order that hosts are processed order: inventory | sorted | reverse_* | shuffle # Not new, but feels related strategy: linear | free ...

Slide 8

Slide 8 text

Host 1 Host 2 Host 3 Host 4 Host 5 Inventory Task 1 Task 2 Task 3 This slide rocks with animation, but is worthless when static. You should have seen the preso live!!

Slide 9

Slide 9 text

Host 1 Host 2 Host 3 Host 4 Inventory Task 1 Task 2 Task 3 This slide rocks with animation, but is worthless when static. You should have seen the preso live!! Forks == 2

Slide 10

Slide 10 text

files templates ansible-vault vars files templates vars files templates vars ansible-playbook files templates vars

Slide 11

Slide 11 text

# Prompt for password > ansible-playbook \ --ask-vault-pass site.yml # Credentials in file > ansible-playbook \ --vault-password-file dev-pass site.yml

Slide 12

Slide 12 text

# Single password Prompt > ansible-playbook \ --vault-id @prompt site.yml # Multi-password > ansible-playbook \ --vault-id cloud@prompt \ --vault-id app@mypassfile \ site.yml

Slide 13

Slide 13 text

> ansible-config Usage: ansible-config [view|dump|list] [ansible.cfg] View, edit, and manage ansible configuration. Options: -c CONFIG_FILE, --config=CONFIG_FILE path to configuration file, defaults to first file found in precedence.

Slide 14

Slide 14 text

Filters in Ansible are from Jinja2, and are used for transforming data inside a template expression. # Default values {{ my_var | default(‘foo’) }} ➠ foo (if var undefined) # Transforming output {{ my_var | to_nice_json(indent=2) }} ➠ { … } # Regex {{ 'ansible' | regex_replace('^a.*i(.*)$', 'a\\1') }} ➠ able

Slide 15

Slide 15 text

● ipaddr filter gained several new suboptions ○ First_usable, ip/prefix, Ip_netmask, last_usable, next_usable, network_id, network/prefix, network_netmask ○ Network_wildcard, Previous_usable, Range_usable, Size_usable, wildcard ● Next_nth_usable, network_in_network, Network_in_usable, previous_nth_usable ● Parse_cli, parse_cli_textfsm # Subnet membership {{ '192.168.1.1/24' | network_in_network('192.168.1.1/25') }} # Subnet expansion {{ '192.168.1.1/24' | next_nth_usable(50) }} # Extract CLI element {{ output | parse_cli_textfsm('path/to/fsm') }}

Slide 16

Slide 16 text

# Display year-month-day {{ '%Y-%m-%d' | strftime }} # Display hour:min:sec {{ '%H:%M:%S' | strftime }} # Use ansible_date_time.epoch fact {{ '%Y-%m-%d %H:%M:%S' | strftime(ansible_date_time.epoch) }} # Use arbitrary epoch value {{ '%Y-%m-%d' | strftime(0) }} # => 1970-01-01 {{ '%Y-%m-%d' | strftime(1441357287) }} # => 2015-09-04

Slide 17

Slide 17 text

{{ "http://user:[email protected]:9000/dir/index.html? query=term#frament" | urlsplit }} # => # { # "fragment": "fragment", # "hostname": "www.acme.com", # "netloc": "user:[email protected]:9000", # "password": "password", # "path": "/dir/index.html", # "port": 9000, # "query": "query=term", # "scheme": "http", # "username": "user" # }

Slide 18

Slide 18 text

{{ "http://user:[email protected]:9000/dir/index.html? query=term#frament" | urlsplit(‘port’) }} # => 9000

Slide 19

Slide 19 text

● ● ● ● ● ● ● ●

Slide 20

Slide 20 text

Skip a particular step based on a variable or fact tasks: - name: "shut down Debian flavored systems" command: /sbin/shutdown -t now when: ansible_os_family == "Debian"

Slide 21

Slide 21 text

tasks: - debug: msg="all are true!" when: list_one is all vars: list_one: - 1 - 3 == 3 - True list_two: - False - True - debug: msg="at least one is true" when: list_two is any

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

● win_defrag ● win_domain_group ● win_domain_user ● win_dsc ● win_eventlog ● win_eventlog_entry ● win_firewall ● win_group_membership ● win_hotfix ● win_mapped_drive ● win_pagefile ● win_power_plan ● win_psmodule ● win_rabbitmq_plugin ● win_route ● win_security_policy ● win_toast ● win_user_right ● win_wait_for ● win_wakeonlan

Slide 26

Slide 26 text

● win_defrag ● win_domain_group ● win_domain_user ● win_dsc ● win_eventlog ● win_eventlog_entry ● win_firewall ● win_group_membership ● win_hotfix ● win_mapped_drive ● win_pagefile ● win_power_plan ● win_psmodule ● win_rabbitmq_plugin ● win_route ● win_security_policy ● win_toast ● win_user_right ● win_wait_for ● win_wakeonlan

Slide 27

Slide 27 text

# Playbook example - name: Extract zip file win_dsc: resource_name: archive ensure: Present path: "C:\\Temp\\zipfile.zip" destination: "C:\\Temp\\Temp2" - name: Invoke DSC with check mode win_dsc: resource_name: windowsfeature name: telnet-client

Slide 28

Slide 28 text

● ● -v ● ● ● ●

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

@KeithResar @KeithResar