More Related Content
Similar to Ansible intro (20)
Ansible intro
- 2. o Introduction
o Install
o Inventory
o Ad-Hoc/CLI
o Playbook
Outline
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY2
- 3. o What
• Ansible is an IT automation tool. It can configure systems, deploy software, and orchestrate more
advanced IT tasks such as continuous deployments or zero downtime rolling updates.
o Current version
• Community: Ansible 2.2(stable), 2.3(devel)
• Enterprise: Ansible tower
o Feature
• SSH Protocol
• Agent-less (push mode)
• Idempotent
• Role defined
• DSL: YAML(yml), Jinja2(j2)
Introduction
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY3
https://www.ansible.com/
- 5. o Requirements
• Python 2.6, 2.7 for control
• Python 2.4, 2.5 for managed
o # method1: install via yum
centos:~ # yum install epel-release
centos:~ # yum install ansible
o # method2: install via pip
centos:~ # pip install ansible
Install
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY5
- 6. o Config Order
1. ANSIBLE_CONFIG environment variable
2. ./ansible.cfg
3. ~/.ansible.cfg
4. /etc/ansible/ansible.cfg
o control:~ # cat /etc/ansible/ansible.cfg
[defaults]
ansible_python_interpreter = /usr/bin/python2
nocows = 1
...
Config File
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY6
- 7. o Main command
• ansible
• ansible-playbook
• ansible-doc
o Other command
• ansible-galaxy
• ansible-pull
• ansible-console
• ansible-vault
Command
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY7
- 8. Inventory
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY8
Ref: http://docs.ansible.com/ansible/intro_inventory.html
host group
group of group
group variable
- 9. o control:~ # cat hosts
node1 ansible_ssh_host=192.168.0.11 ansible_ssh_user=root
ansible_ssh_pass=password ansible_become_pass=password
node2 ansible_ssh_host=192.168.0.12 ansible_ssh_user=root
ansible_ssh_private_key_file=private_file
o # run ansible via ad-hoc
control:~ # ansible all -i hosts -m ping -vvv
control:~ # ansible node1 -i hosts -m command -a uptime
Ad-Hoc/CLI
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY9
module
host inventory
- 10. o Ansible Module
• http://docs.ansible.com/ansible/modules_by_category.html
Module
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY10
- 11. Module – setup (gather fact)
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY11
playbook content
- 12. ---
- hosts: all
tasks:
- name: Hello World
shell: echo "hello world"
[
{host: "all”},
{
tasks: [
{ name: "Hello World",
shell: "echo "hello world“”}
]
}
]
YAML & JSON
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY12
- 13. Playbook - content
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY13
module
disable gather fact
- 16. Playbook - example
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY16
copy file from control to managed
loop
notify
condition
- 21. o Ansible
o Ansible Document
o Ansible: Up and Running
o 現代 IT 人一定要知道的 Ansible 自動化組態技巧
Reference
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY21
- 22. Thank you!
© 2016 BROCADE COMMUNICATIONS SYSTEMS, INC. INTERNAL USE ONLY
@ruckuswirelessfacebook.com/ruckuswirelesswww.ruckuswireless.com
22