Ansible log


Posted:   |  More posts about ansible sysadmin devops python

Ansible is an example of clash between sysadmin and developer mentality.
Sysadmin tend to think about system as a whole while developer always think about their specific apps. While developer want to isolate, sysadmin want to 'propagate', if I can use such term.

I want to try ansible and see if it can be a better alternative to Fabric. The first thing to do of course to install it. Since I'd already have my deployment tools environment based on buildout, I want to install ansible using my buildout config, rather than making it system-wide, or even 'user-wide' (mean install it to my $HOME dir). I don't want to pollute my $HOME, let alone the system. It's impossible to install ansible with buildout since it want to write to /usr/share/ansible and buildout will raise SandboxViolationError exception.

Fortunately it's still installable through pip and also work inside virtualenv.
Running buildout under virtualenv still raise SandboxViolationError though. Enough rant, let's get started:-

virtualenv test-ansible
cd test-ansible
./bin/pip install ansible

I spent quite sometime reading ansible docs to finally grasp the concept of inventory. It's a place (a text file) where you define all the servers you want to manage. By default ansible will look in /etc/ansible/hosts file. You can change this through configuration file $HOME/.ansible.cfg and set the value hostfile = /etc/ansible/hosts.

- hosts: pipz
- name: Add main user
  user: name=kamal
        home=/home/kamal

- name: Set up authorized key for kamal
  authorized_key: user=kamal
                  state=present
                  key="{{ item }}"
  with_file:
    - /home/kamal/.ssh/id_rsa-do.pub

Error: Host declaration is required

Missing tasks

- hosts: pipz
  tasks:
    - name: Add main user
      user: name=kamal
            home=/home/kamal

    - name: Set up authorized key for kamal
      authorized_key: user=kamal
                      state=present
                      key="{{ item }}"
      with_file:
        - /home/kamal/.ssh/id_rsa-do.pub
./bin/ansible-playbook main.yml -i ansible_hosts.ini -u root

http://lextoumbourou.com/blog/posts/getting-started-with-ansible/#part-3

Comments powered by Disqus

About me

Web developer in Malaysia. Currently work at MARIMORE Inc building internet services using Python and Django web framework.

ImportError is an error message emitted by Python when it failed to load certain module as requested by programmer. It's a very common error when someone new to the language trying it out. This website on the same theme, will try provide help for newcomers on any technologies to overcome their first hurdle.

Try most of the examples you may find here on Digital Ocean cloud service. They provide excellent VPS at a very cheaper price. Using this referral link you'll get USD10 credits upon sign up. That's enough to run single VPS with 1GB RAM for a month.

Others

I can also be found at the following sites:-

  • http://k4ml.blogspot.com/
  • http://k4ml.github.io/
  • http://metak4ml.blogspot.com/
  • http://www.mydev.my/
  • http://github.com/k4ml/

Disclaimers

The postings on this site are my own and don't necessarily represent my employer's positions, strategies or opinions.

Share