Difference between revisions of "Ansible"

From Alpine Linux
Jump to: navigation, search
(First test)
m
Line 1: Line 1:
[http://ansible.cc/ ansible] is a simple configuration management, deployment, task-execution, and multinode orchestration framework. It uses SSH for the communication between the involved systems, no server or client daemons are needed, and no additional software on client boxes is required.
+
{{Draft|At the moment Alpine Linux can't be used }}
 +
 
 +
[http://ansible.cc/ ansible] is a simple configuration management, deployment, task-execution, and multinode orchestration framework. It uses SSH for the communication between the involved systems, no server or client daemons are needed, and no additional software beside Python on client boxes is required.
  
 
= Installation of ansible =
 
= Installation of ansible =
ansible is available in ''testing''.
+
ansible is available in ''testing''. The latest package is broken, sorry.
  
 
{{Cmd|apk add ansible -U -X http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}
 
{{Cmd|apk add ansible -U -X http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted}}
  
= Setup SSH =
+
= Managed nodes =
For every system you want to manage, you need to have the SSH key in the <code>authorized_keys</code> file of the target system.
+
There are only minimal requirements for the clients. For every system you want to manage, you need to have the client's SSH key in the <code>authorized_keys</code> file of the management system and Python.
 +
 
 +
Install the Python package.
 +
 
 +
{{Cmd|apk add python}}
 +
 
 +
== Create a SSH key ==
 +
Generate a SSH key for the managed node. It's recommended to use a key which is protected with a password.
  
{{Cmd|ssh-copy-id -i ~/.ssh/id_rsa.pub root@[IP of the target system]}}
+
{{Cmd|ssh-keygen -t rsa}}
 +
 
 +
== Transfer the SSH key ==
 +
There are two ways to do it. From a default Alpine installation you can use ssh and cat to do it.
 +
 
 +
{{Cmd|ssh root@[IP of the management system] 'cat ~/.ssh/id_rsa.pub' | cat - >> ~/.ssh/authorized_keys}}
 +
 
 +
If you are planning to use additional features of SSH. <code>ssh-copy-id</code>, which is provided by the <code>openssh-client</code> package, can help you with the key setup.
 +
 
 +
{{Cmd|ssh-copy-id -i ~/.ssh/id_rsa.pub root@[IP of the management system]}}
  
 
= Setup hosts =
 
= Setup hosts =
Line 22: Line 40:
 
= First test =
 
= First test =
  
 +
{{Cmd|$ ansible all -m ping -u you --sudo}}
  
{{Cmd|$ ansible all -m ping -u you --sudo}}
+
= Playbooks =
 +
When writing playbooks for Alpine Linux there are some issues:
 +
 
 +
# At the moment APK is not supported natively by Ansible. But the following will work {{Cmd|action: command /sbin/apk add lighttpd}}
 +
# Same with the OpenRC, the [[Alpine_Linux_Init_System|Init System]] {{Cmd|action: command /etc/init.d/lighttpd start}}
 +
# If you are going to re-use playbooks from other Linux distribution, please keep in mind that Alpine Linux uses different paths for the binaries. <code>/bin/rm</code>

Revision as of 17:10, 6 March 2013

Underconstruction clock icon gray.svg
This material is work-in-progress ...

At the moment Alpine Linux can't be used
(Last edited by Fab on 6 Mar 2013.)

ansible is a simple configuration management, deployment, task-execution, and multinode orchestration framework. It uses SSH for the communication between the involved systems, no server or client daemons are needed, and no additional software beside Python on client boxes is required.

Installation of ansible

ansible is available in testing. The latest package is broken, sorry.

apk add ansible -U -X http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted

Managed nodes

There are only minimal requirements for the clients. For every system you want to manage, you need to have the client's SSH key in the authorized_keys file of the management system and Python.

Install the Python package.

apk add python

Create a SSH key

Generate a SSH key for the managed node. It's recommended to use a key which is protected with a password.

ssh-keygen -t rsa

Transfer the SSH key

There are two ways to do it. From a default Alpine installation you can use ssh and cat to do it.

ssh root@[IP of the management system] 'cat ~/.ssh/id_rsa.pub'

If you are planning to use additional features of SSH. ssh-copy-id, which is provided by the openssh-client package, can help you with the key setup.

ssh-copy-id -i ~/.ssh/id_rsa.pub root@[IP of the management system]

Setup hosts

Add all your remote systems to /etc/ansible/hosts. For details, please refer to Hosts and Groups in the ansible documentation.

Contents of /etc/ansible/hosts

192.168.1.50 10.0.0.12 webserver.example.org mail.example.org

First test

$ ansible all -m ping -u you --sudo

Playbooks

When writing playbooks for Alpine Linux there are some issues:

  1. At the moment APK is not supported natively by Ansible. But the following will work

    action: command /sbin/apk add lighttpd

  2. Same with the OpenRC, the Init System

    action: command /etc/init.d/lighttpd start

  3. If you are going to re-use playbooks from other Linux distribution, please keep in mind that Alpine Linux uses different paths for the binaries. /bin/rm