Download presentation
Presentation is loading. Please wait.
1
IT Atoumation / Conf. Mgmt...
...with Ansible
2
Handcrafted Servers are
hard to maintain very time/cost intensive setup is not easily reproducible many times very buggy
3
Options to automate IT Chef Puppet Salt Ansible
4
Reasons for Ansible No Master No Agents Configuration in Yaml
Very easy to learn, excellent documentation No special protocols Ansible works via SSH. No Master Server! No Agent on the Server is required Can be used for ad-hoc configuration
5
Ansible Concepts Inventory Playbooks Roles Tasks / Handlers / Vars
Modules
6
Inventory Inventory files are simple text files which describe your servers. IP Addresses or DNS Names grouped by names. List of target hosts. Usually located in /etc/ansible/hosts [web_sever] [proxy_servers] [other] new.i803.zz
7
Inventory Inventory files can take advantage of
[web-servers] Web[1:3].i803.zz [proxy] {{my_little_proxyserver}} Inventory files can take advantage of variables and enumerations
8
Playbooks YAML Files Declaratively define your configuration
Can contain many “Plays” targeting different Groups Little learning curve to get started with Can be large and complex, but still manageable
9
Playbooks --- - hosts: dev_servers user: ubuntu sudo: true roles:
- java - memcached Hosts, group name from the inventory file User, sudo: server auth Roles: Role which should be installed on the server
10
Roles and modules While it is possible to write a playbook in one very large file (and you might start out learning playbooks this way), eventually you’ll want to reuse files and start to organize things. A role is the Ansible way of bundling automation content and making it reusable. If you're not familiar with the Ansible role concept, think of include files used in a programming language. An include file allows the programmer to organize code into reusable modules.
11
Roles and modules Ansible ships with a number of modules (called the 'module library') that can be executed directly on remote hosts or through Playbooks. Users can also write their own modules. These modules can control system resources, like services, packages, or files (anything really), or handle executing system commands. So, the difference: roles are something you create, modules are built-in
12
Roles and modules Role --- - hosts: droplets tasks:
- name: Installs nginx web server apt: pkg=nginx state=installed update_cache=true notify: - start nginx handlers: - name: start nginx service: name=nginx state=started Module --- - name: update debian packages apt: update_cache=true - name: install Java JDK apt: name=openjdk-7-jdk state=present
13
Playbooks, conclusions
Expressed in YAML language Composed of one or more “plays” in a list Allowing multi-machine deployments orchestration
14
Playbook - play hosts : one or more groups or host patterns
○ remote_user : the name of the remote user account (per play or task) ○ sudo : run tasks using sudo (per play or task) ○ sudo_user : sudo to a different user than root Are executed in order against all machines matched by the host pattern ○ May be Included from other files tasks: - include: tasks/foo.yml ○ Hosts with failed tasks are taken out for the entire playbook ○ Each task executes a module with specific options ○ Modules are idempotent in order to bring the system to the desired state - name: {task name} {module}: {options} Playbook - handlers ○ Notifications may be triggered at the end of each block of tasks whenever a change has been made on the remote system ○ Handlers are referenced by name - name: template configuration file template: src=template.j2 dest=/etc/foo.conf notify: - restart apache … handlers: - name: restart apache service: name=apache state=restarted
15
Playbook - roles Based on a known file structure
16
Playbook - variables
17
What is YAML YAML is a Data Serialization Language.
A New Language for Data Goals: YAML documents are very readable by humans. YAML interacts well with scripting languages. YAML uses host languages native data structures. YAML has a consistent information model. YAML enables stream-based processing. YAML is expressive and extensible. YAML is easy to implement. Reality: White space syntax No tabs Where did I made mistake?
18
Lab In this Lab you will learn How to set up ansible
How to create and run very basic playbook How to set up ansible Right Way :) How to customize and use ready-made complex playbooks How to Automate complex tasks by using ready made playbooks
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.