Ansible: Unterschied zwischen den Versionen
Aus Alexander's Wiki
Admin (Diskussion | Beiträge) |
Admin (Diskussion | Beiträge) |
||
Zeile 41: | Zeile 41: | ||
</source> | </source> | ||
= | = playbook.yml = | ||
<source lang="bash" encl="div"> | <source lang="bash" encl="div"> | ||
- hosts: all | - hosts: all | ||
become: true | |||
vars: | vars: | ||
packages: [ 'hsm-base', 'hsm-sqlanywhere', 'hsm-sqlanywhere-config' ] | packages: [ 'hsm-base', 'hsm-sqlanywhere', 'hsm-sqlanywhere-config' ] | ||
tasks: | tasks: | ||
- name: Update apt | |||
apt: update_cache=yes | |||
- name: Install Package | - name: Install Package | ||
apt: name={{ item }} state=latest | apt: name={{ item }} state=latest | ||
with_items: packages | with_items: packages | ||
</source> | </source> |
Version vom 17. Oktober 2016, 12:35 Uhr
Ansible Terms
* Controller Machine: the machine where Ansible is installed, responsible for running the provisioning on the servers you are managing * Inventory: an INI file that contains information about the servers you are managing * Playbook: the entry point for Ansible provisionings, where the automation is defined through tasks using YAML format * Task: a block that defines a single procedure to be executed, e.g.: install a package * Module: a module typically abstracts a system task, like dealing with packages or creating and changing files. Ansible has a multitude of built-in modules, but you can also create custom ones * Role: a pre-defined way for organizing playbooks and other files in order to facilitate sharing and reusing portions of a provisioning * Play: a provisioning executed from start to finish is called a play * Facts: global variables containing information about the system, like network interfaces or operating system * Handlers: used to trigger service status changes, like restarting or stopping a service
Ansible provisionings are written using YAML, a simple data serialization language.
Installation (Ubuntu)
apt-get install software-properties-common
apt-add-repository ppa:ansible/ansible
apt-get update
apt-get install ansible
Installation (Manuell, Control machine)
git clone git://github.com/ansible/ansible.git --recursive
cd ./ansible
source ./hacking/env-setup
apt-get install build-essential libssl-dev libffi-dev python-dev
apt-get install python-setuptools
easy_install pip
pip install paramiko PyYAML Jinja2 httplib2 six
Update (Manuell)
Beim Update von Ansible müssen auch die Submodule mit upgedated werden. Diese geschieht durch die beiden Befehle:
git pull --rebase
git submodule update --init --recursive
playbook.yml
- hosts: all
become: true
vars:
packages: [ 'hsm-base', 'hsm-sqlanywhere', 'hsm-sqlanywhere-config' ]
tasks:
- name: Update apt
apt: update_cache=yes
- name: Install Package
apt: name={{ item }} state=latest
with_items: packages