Professional Documents
Culture Documents
Ansible Advanced
Oleg Fiksel
oleg.fiksel@cspi.com | oleg@fiksel.info
FrOSCon 2016
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
A GENDA
A BOUT
I NTRODUCTION
P LAYBOOKS IN DEEP
W HAT ’ S NEW
Amazon AWS
Upcoming topics
E ND
Q&A
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
A BOUT ME
1
About CSPi
2
Wikipedia: MODCOMP
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
W HY ANSIBLE ?
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
W HY ANSIBLE ?
I Fresh
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
W HY ANSIBLE ?
I Fresh
I Started February 2012
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
W HY ANSIBLE ?
I Fresh
I Started February 2012
I Core rewrite January 2016
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
W HY ANSIBLE ?
I Fresh
I Started February 2012
I Core rewrite January 2016
I Simple syntax
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
W HY ANSIBLE ?
I Fresh
I Started February 2012
I Core rewrite January 2016
I Simple syntax
I Bloody Enterprise compatible
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
W HY ANSIBLE ?
I Fresh
I Started February 2012
I Core rewrite January 2016
I Simple syntax
I Bloody Enterprise compatible
I Works with no agents on the systems
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
W HY ANSIBLE ?
I Fresh
I Started February 2012
I Core rewrite January 2016
I Simple syntax
I Bloody Enterprise compatible
I Works with no agents on the systems
I Works via jumphosts
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
W HY ANSIBLE ?
I Fresh
I Started February 2012
I Core rewrite January 2016
I Simple syntax
I Bloody Enterprise compatible
I Works with no agents on the systems
I Works via jumphosts
I Works on stripped down / hardened systems
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
Most work in ansible is handled by modules 1 .
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
Most work in ansible is handled by modules 1 .
I connection modules
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
Most work in ansible is handled by modules 1 .
I connection modules
I connect to machines
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
Most work in ansible is handled by modules 1 .
I connection modules
I connect to machines
I lookup modules
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
Most work in ansible is handled by modules 1 .
I connection modules
I connect to machines
I lookup modules
I give data
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
Most work in ansible is handled by modules 1 .
I connection modules
I connect to machines
I lookup modules
I give data
I filter modules
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
Most work in ansible is handled by modules 1 .
I connection modules
I connect to machines
I lookup modules
I give data
I filter modules
I transform data
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
Most work in ansible is handled by modules 1 .
I connection modules
I connect to machines
I lookup modules
I give data
I filter modules
I transform data
I callback modules
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
Most work in ansible is handled by modules 1 .
I connection modules
I connect to machines
I lookup modules
I give data
I filter modules
I transform data
I callback modules
I register events that happen when tasks are executed
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
Most work in ansible is handled by modules 1 .
I connection modules
I connect to machines
I lookup modules
I give data
I filter modules
I transform data
I callback modules
I register events that happen when tasks are executed
I task modules
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
Most work in ansible is handled by modules 1 .
I connection modules
I connect to machines
I lookup modules
I give data
I filter modules
I transform data
I callback modules
I register events that happen when tasks are executed
I task modules
I self contained script
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
Most work in ansible is handled by modules 1 .
I connection modules
I connect to machines
I lookup modules
I give data
I filter modules
I transform data
I callback modules
I register events that happen when tasks are executed
I task modules
I self contained script
I any programming language (core modules - python only)
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
Most work in ansible is handled by modules 1 .
I connection modules
I connect to machines
I lookup modules
I give data
I filter modules
I transform data
I callback modules
I register events that happen when tasks are executed
I task modules
I self contained script
I any programming language (core modules - python only)
I do the heavy lifting
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
Most work in ansible is handled by modules 1 .
I connection modules
I connect to machines
I lookup modules
I give data
I filter modules
I transform data
I callback modules
I register events that happen when tasks are executed
I task modules
I self contained script
I any programming language (core modules - python only)
I do the heavy lifting
I copied to the target machine
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
Most work in ansible is handled by modules 1 .
I connection modules
I connect to machines
I lookup modules
I give data
I filter modules
I transform data
I callback modules
I register events that happen when tasks are executed
I task modules
I self contained script
I any programming language (core modules - python only)
I do the heavy lifting
I copied to the target machine
I executed with (json) input
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
M ODULE INSIGHTS
Most work in ansible is handled by modules 1 .
I connection modules
I connect to machines
I lookup modules
I give data
I filter modules
I transform data
I callback modules
I register events that happen when tasks are executed
I task modules
I self contained script
I any programming language (core modules - python only)
I do the heavy lifting
I copied to the target machine
I executed with (json) input
I (json) output is registered
1
Ansible - Developing Plugins
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
P LAYBOOKS IN DEEP
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
TAGS
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
TAGS
1 # main.yml
2 ---
3 − h o s t s : webservers
4 gather_facts: false
5 tasks:
6 - package:
7 name: "lighttpd"
8 state: installed
9 tags:
10 - packages
11 - template:
12 s r c : "template/lighttpd.j2"
13 d e s t : "/etc/lighttpd/lighttpd.conf"
14 tags:
15 - configuration
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
TAGS
1 # main.yml
2 ---
3 − h o s t s : webservers
4 gather_facts: false
5 tasks:
6 - package:
7 name: "lighttpd"
8 state: installed
9 tags:
10 - packages
11 - template:
12 s r c : "template/lighttpd.j2"
13 d e s t : "/etc/lighttpd/lighttpd.conf"
14 tags:
15 - configuration
Run:
a n s i b l e −playbook main . yml −−t a g s packages
C USTOM ACTIONS
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
C USTOM ACTIONS
1 ---
2 − i n c l u d e _ v a r s : "includes/{{ ansible_os_family }}.yml"
3 − name: "remove the apache package"
4 a c t i o n : "{{custom_package_mgr}} name={{apache}} state=absent"
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
I NTERACTION
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
COMMANDLINE / FILE
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
COMMANDLINE / FILE
1 # vars . json
2 { " apache_hostname " : " example . com" }
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
1
Ansible - Playbook Prompts
2
Ansible - Pause Module
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
1 ---
2 − hosts: localhost
3 gather_facts: false
4 vars_prompt:
5 - name: "name"
6 prompt: "What is your name?"
7 p r i v a t e : no
8 - name: "location"
9 prompt: "What is you location?"
10 p r i v a t e : no
11 tasks:
12 - debug:
13 msg: "{{name}}, let me think for a moment..."
14 - pause:
15 seconds: 10
16 - debug:
17 msg: "Let me guess, you are now at {{location}}?"
1
Ansible - Playbook Prompts
2
Ansible - Pause Module
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
P LAYBOOK AS AN EXECUTABLE
1
Example from: Ansible Webinar - Tips and Tricks by Brian Coca
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
P LAYBOOK AS AN EXECUTABLE
Use Shebang to run ansible as an executable.
1 #!/usr/bin/ansible-playbook
2 ---
3 − hosts: a l l
4 gather_facts: false
5 # sudo: true
6 vars_files:
7 - d e p a r t e d _ u s e r s . yml
8 tasks:
9 - name: D e l e t e departed u s e r s and a l l i t ’s files
10 u s er: name = { { item } } s t a t e = a b s e n t remove=yes
11 with_items: "{{departed}}"
1
Example from: Ansible Webinar - Tips and Tricks by Brian Coca
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
P LAYBOOK AS AN EXECUTABLE
Use Shebang to run ansible as an executable.
1 #!/usr/bin/ansible-playbook
2 ---
3 − hosts: a l l
4 gather_facts: false
5 # sudo: true
6 vars_files:
7 - d e p a r t e d _ u s e r s . yml
8 tasks:
9 - name: D e l e t e departed u s e r s and a l l i t ’s files
10 u s er: name = { { item } } s t a t e = a b s e n t remove=yes
11 with_items: "{{departed}}"
1 # departed_users.yml
2 ---
3 − departed: [ "toor" , "admin" ]
1
Example from: Ansible Webinar - Tips and Tricks by Brian Coca
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
P LAYBOOK AS AN EXECUTABLE
Use Shebang to run ansible as an executable.
1 #!/usr/bin/ansible-playbook
2 ---
3 − hosts: a l l
4 gather_facts: false
5 # sudo: true
6 vars_files:
7 - d e p a r t e d _ u s e r s . yml
8 tasks:
9 - name: D e l e t e departed u s e r s and a l l i t ’s files
10 u s er: name = { { item } } s t a t e = a b s e n t remove=yes
11 with_items: "{{departed}}"
1 # departed_users.yml
2 ---
3 − departed: [ "toor" , "admin" ]
. / d e l e t e _ d e p a r t e d _ u s e r s . yml −i . . / i n v e n t o r y −l h o s t 1
1
Example from: Ansible Webinar - Tips and Tricks by Brian Coca
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
D ELEGATION
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
D ELEGATION
1 ---
2 − name: shush n a g i o s b e f o r e deployment
3 n a gi o s:
4 action: silence
5 h o s t : "{{inventory_hostname}}"
6 d e l e g a t e _ t o : "{{nagios_host}}"
7
8 . . . deployment
9
10 − name: unshush n a g i o s a f t e r deployment
11 n a gi o s:
12 action: unsilence
13 h o s t : "{{inventory_hostname}}"
14 d e l e g a t e _ t o : "{{nagios_host}}"
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
L OOKUPS
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
L OOKUPS 1/4
L OOKUPS 1/4
L OOKUPS 2/4
L OOKUPS 2/4
L OOKUPS 3/4
L OOKUPS 3/4
L OOKUPS 4/4
F ILTERS
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
F ILTERS
More information:
I http://docs.ansible.com/ansible/playbooks_filters.html
I http://jinja.pocoo.org/docs/dev/templates/#builtin-filters
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
E XAMPLE 1
E XAMPLE 2
1 ---
2 − hosts: localhost
3 gather_facts: false
4 tasks:
5 - debug:
6 msg: "{{ ’ansible’ | regex_replace(’^a.*i(.*)$’, ’a\\1’) }}"
Produces: “able”
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
VARIABLE VALIDATION
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
VARIABLE VALIDATION
1 ---
2 − hosts: a l l
3 g a t h e r _ f a c t s : no
4 tasks:
5 - debug: msg = { { hostname | mandatory } }
6 - debug: msg = { { i p | mandatory } }
7 ...
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
I NCLUDES
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
I NCLUDES
1 ---
2 − servers: a l l
3 tasks:
4 - i n c l u d e : set_mysql_password . yml mysql_user= r o o t mysql_pass
= { { var_mysql_pass } }
5 ...
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
R OLES
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
R OLES
1 # sample r o l e s t r u c t u r e
2 roles/
3 common/
4 files/
5 templates/
6 tasks/
7 handlers/
8 vars/
9 defaults/
10 meta/
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
I NCLUDES V. S . R OLES
I NCLUDES V. S . R OLES
IGNORE _ ERRORS
ASSERT
1 ---
2 − hosts: localhost
3 gather_facts: false
4 vars_prompt:
5 - name: "name"
6 prompt: "What is your name?"
7 # show input contents
8 p r i v a t e : no
9 tasks:
10 - name: Very s e c u r e u s e r v a l i d a t i o n
11 assert:
12 t h a t : "name == ’Oleg’"
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
FAIL
1 ---
2 − hosts: localhost
3 gather_facts: false
4 vars_prompt:
5 - name: "name"
6 prompt: "What is your name?"
7 # show input contents
8 p r i v a t e : no
9 tasks:
10 - name: Very s e c u r e u s e r v a l i d a t i o n
11 fail:
12 msg: "You are not allowed to run this playbook, {{name}}!"
13 when: "name != ’Oleg’"
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
1
Details: Ansible 2.0 Release Notes
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
I Task Blocks
1
Details: Ansible 2.0 Release Notes
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
I Task Blocks
I Playbook parsing and Error Reporting improvements
1
Details: Ansible 2.0 Release Notes
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
I Task Blocks
I Playbook parsing and Error Reporting improvements
I Syntax error shows the exact place in a playbook and gives
sugestions
1
Details: Ansible 2.0 Release Notes
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
I Task Blocks
I Playbook parsing and Error Reporting improvements
I Syntax error shows the exact place in a playbook and gives
sugestions
I No more escaping of escapings needed (\\\\)
1
Details: Ansible 2.0 Release Notes
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
I Task Blocks
I Playbook parsing and Error Reporting improvements
I Syntax error shows the exact place in a playbook and gives
sugestions
I No more escaping of escapings needed (\\\\)
I Dynamic Includes
1
Details: Ansible 2.0 Release Notes
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
I Task Blocks
I Playbook parsing and Error Reporting improvements
I Syntax error shows the exact place in a playbook and gives
sugestions
I No more escaping of escapings needed (\\\\)
I Dynamic Includes
I Execution Strategy Plugins
1
Details: Ansible 2.0 Release Notes
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
1 tasks:
2 - block:
3 - debug: msg=’i execute normally’
4 - command: /bin/ f a l s e
5 - debug: msg=’i never execute, cause ERROR!’
6 rescue:
7 - debug: msg=’I caught an error’
8 - command: /bin/ f a l s e
9 - debug: msg=’I also never execute :-(’
10 always:
11 - debug: msg="this always executes"
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
D YNAMIC INCLUDES
1
Porting guide to ansible 2.0
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
D YNAMIC INCLUDES
1
Porting guide to ansible 2.0
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
D YNAMIC INCLUDES
1
Porting guide to ansible 2.0
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
D YNAMIC INCLUDES
1
Porting guide to ansible 2.0
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
D YNAMIC INCLUDES
1
Porting guide to ansible 2.0
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
D YNAMIC INCLUDES
1
Porting guide to ansible 2.0
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
D YNAMIC INCLUDES
1
Porting guide to ansible 2.0
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
E XECUTION STRATEGIES
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
E XECUTION STRATEGIES
host2 host1
task1=1sec
task1=5sec
task2=5sec
task2=9sec
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
task1=1sec task1=1sec
task1=5sec task1=5sec
t1=5sec
task2=9sec
task2=5sec task2=5sec
t1=5sec
task2=9sec
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
task1=1sec task1=1sec
task1=5sec task1=5sec
t1=5sec task1=5sec
task2=9sec
task2=5sec task2=5sec
t1=5sec task2=5sec
task2=9sec
task1=1sec
task2=9sec
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
1 # File structure :
2
3 . / d e p l o y _ f a c t s . yml
4 ./ f i l e s
5 ./ f i l e s /host1 . f a c t
6 ./ f i l e s /host2 . f a c t
7 . / run . yml
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
1 # File structure :
2
3 . / d e p l o y _ f a c t s . yml
4 ./ f i l e s
5 ./ f i l e s /host1 . f a c t
6 ./ f i l e s /host2 . f a c t
7 . / run . yml
1 # f i l e s / host1 . f a c t
2 [ general ]
3 t 1 =1
4 t 2 =9
1 # f i l e s / host2 . f a c t
2 [ general ]
3 t 1 =5
4 t 2 =5
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
1 # deploy_facts.yml
2 ---
3 − hosts: a l l
4 tasks:
5 - debug:
6 msg: "{{ ansible_local[’times’][’general’] }}"
7 i g n o r e _ e r r o r s : True
8 - file:
9 path: ’/etc/ansible/facts.d’
10 state: directory
11 - copy:
12 s r c : "files/{{ inventory_hostname }}.fact"
13 d e s t : "/etc/ansible/facts.d/times.fact"
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
1 # run.yml
2 ---
3 − hosts: a l l
4 strategy: free
5 # strategy: linear
6 # serial: 1
7 tasks:
8 - debug:
9 msg: "{{ ansible_local[’times’][’general’] }}"
10 - shell:
11 cmd: "sleep {{ ansible_local[’times’][’general’][’t1’] }}"
12 - shell:
13 cmd: "sleep {{ ansible_local[’times’][’general’][’t2’] }}"
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
1
Details: Ansible - Package Module
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
1 ---
2 − package: name= g i t s t a t e = p r e s e n t
1
Details: Ansible - Package Module
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
How to solve?
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
1 # includes/Debian.yml
2 ---
3 apache: "apache2"
1 # includes/RedHat.yml
2 ---
3 apache: "httpd"
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
IPTABLES MODULE
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
IPTABLES MODULE
1 ---
2 # Block specific IP
3 − iptables:
4 i p _ v e r s i o n : ipv4
5 ch a i n : INPUT
6 source: 8 . 8 . 8 . 8
7 jump: DROP
8 # this must be runned as root (sudo)
9 become: t r u e
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
1
Changelog
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
Currently in development.
1
Changelog
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
Currently in development.
I Added support for binary modules.
"Yeah!" to all Golang programmers.
1
Changelog
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
Currently in development.
I Added support for binary modules.
"Yeah!" to all Golang programmers.
I letsencrypt
1
Changelog
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
Currently in development.
I Added support for binary modules.
"Yeah!" to all Golang programmers.
I letsencrypt
I cisco ASA
1
Changelog
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
Currently in development.
I Added support for binary modules.
"Yeah!" to all Golang programmers.
I letsencrypt
I cisco ASA
I lxd module
1
Changelog
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
Currently in development.
I Added support for binary modules.
"Yeah!" to all Golang programmers.
I letsencrypt
I cisco ASA
I lxd module
I aws_vpc_∗
1
Changelog
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
Currently in development.
I Added support for binary modules.
"Yeah!" to all Golang programmers.
I letsencrypt
I cisco ASA
I lxd module
I aws_vpc_∗
I telegram
1
Changelog
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
Currently in development.
I Added support for binary modules.
"Yeah!" to all Golang programmers.
I letsencrypt
I cisco ASA
I lxd module
I aws_vpc_∗
I telegram
I wakeonlan
1
Changelog
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
Currently in development.
I Added support for binary modules.
"Yeah!" to all Golang programmers.
I letsencrypt
I cisco ASA
I lxd module
I aws_vpc_∗
I telegram
I wakeonlan
I ...
1
Changelog
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
A MAZON AWS
1
Changelog
2
List of cloud modules
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
A MAZON AWS
I Current status
1
Changelog
2
List of cloud modules
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
A MAZON AWS
I Current status
I ansible 2.0 ∼ 70 AWS modules
1
Changelog
2
List of cloud modules
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
A MAZON AWS
I Current status
I ansible 2.0 ∼ 70 AWS modules
I For everthing else use awscli (until module will be
implemented)
1
Changelog
2
List of cloud modules
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
A MAZON AWS
I Current status
I ansible 2.0 ∼ 70 AWS modules
I For everthing else use awscli (until module will be
implemented)
I For better experience
1
Changelog
2
List of cloud modules
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
A MAZON AWS
I Current status
I ansible 2.0 ∼ 70 AWS modules
I For everthing else use awscli (until module will be
implemented)
I For better experience
I Use ansible = 2.0 + Boto3 (long-term Boto will go away)
1
Changelog
2
List of cloud modules
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
A MAZON AWS
I Current status
I ansible 2.0 ∼ 70 AWS modules
I For everthing else use awscli (until module will be
implemented)
I For better experience
I Use ansible = 2.0 + Boto3 (long-term Boto will go away)
I ansible 2.2 (current development) has more aws modules,
see changelog 1 for details
1
Changelog
2
List of cloud modules
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
E XAMPLE
1 ---
2 − name: s ea m le ss deployment
3 h o s t s : nodes_behind_elb
4 serial: 1
5 pre_tasks:
6 - name: g e t ec2 f a c t s
7 ec2_facts:
8 - name: d i a c t i v a t e node i n e l b
9 e c 2 _ e l b : s t a t e = a b s e n t # arguments
10 delegate_to: localhost
11
12 tasks:
13 - name: deploy new s o f t w a r e
14 g i t : # arguments
15
16 post_tasks:
17 - name: a c t i v a t e node i n e l b
18 e c 2 _ e l b : s t a t e = p r e s e n t # arguments
19 delegate_to: localhost
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
U PCOMING TOPICS
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
C OMPLIANCE
1
ansible-lockdown
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
C OMPLIANCE
ansible-lockdown 1
1
ansible-lockdown
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
C OMPLIANCE
ansible-lockdown 1
I goal - implement STIG baseline
1
ansible-lockdown
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
C OMPLIANCE
ansible-lockdown 1
I goal - implement STIG baseline
I IMHO good idea
1
ansible-lockdown
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
C OMPLIANCE
ansible-lockdown 1
I goal - implement STIG baseline
I IMHO good idea
I current status: v0.1
1
ansible-lockdown
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
N ETWORK O RCHESTRATION
1
Ansible - List of Network Modules
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
N ETWORK O RCHESTRATION
1
Ansible - List of Network Modules
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
E XAMPLE
1 ---
2 − hosts: ios1
3 tasks:
4 - ios_command:
5 commands: show running−c o n f i g a l l
6 p r o v i d e r : "{{cli}}"
7 r e g i s t e r : deviceconfig
8
9 - ios_config
10 lines:
11 - d e s c r i p t i o n c o n f i g u r e d by a n s i b l e
12 - i p address 1 0 . 0 . 0 . 1 2 5 5 . 2 5 5 . 2 5 5 . 0
13 - no shutdown
14 p a r e n t s : i n t e r f a c e G i g a b i t E t h e r n e t 0 /1
15 c o n f i g : "{{ deviceconfig.stdout[0] }}"
16 p r o v i d e r : "{{cli}}"
1
Ansible Webcast - Automating your network
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
ANSIBLE - CONTAINER
1
ansible-container readme
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
ANSIBLE - CONTAINER
1
ansible-container readme
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
ANSIBLE - CONTAINER
1
ansible-container readme
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
ANSIBLE - CONTAINER
1
ansible-container readme
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
ANSIBLE - CONTAINER
1
ansible-container readme
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
ANSIBLE - CONTAINER
1
ansible-container readme
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
ANSIBLE - CONTAINER
1
ansible-container readme
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
ANSIBLE - CONTAINER
1
ansible-container readme
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
S UMMARY
1
Playbooks from this talk
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
S UMMARY
1
Playbooks from this talk
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
S UMMARY
I Play the slides after the talk and try things out
1
Playbooks from this talk
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
S UMMARY
I Play the slides after the talk and try things out
1
Playbooks from this talk
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
S UMMARY
I Play the slides after the talk and try things out
1
Playbooks from this talk
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
S UMMARY
I Play the slides after the talk and try things out
1
Playbooks from this talk
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
S UMMARY
I Play the slides after the talk and try things out
1
Playbooks from this talk
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
Q&A
A BOUT I NTRODUCTION P LAYBOOKS IN DEEP W HAT ’ S NEW Amazon AWS Upcoming topics E ND
Thanks!
Oleg Fiksel
oleg.fiksel@cspi.com | oleg@fiksel.info