Jaime Gago Condensing Information Systems From the Vapor Of Data

5Apr/133

Handling directory copy and syncing aka “recursive copy” in Ansible 1.1

This post is no longer relevant as the copy module can do recursive copy since 1.5, also an rsync was module was added
While working on the Matterhorn Ansible playbook I've had to find a solution for copying the content of a directory from the host running the playbook to a group of hosts.Screen Shot 2013-03-30 at 6.07.36 PM

Turns out there are at least 3 ways of doing this and I thought summarizing them in one post would help other folks, worst case scenario it'll serve as a reminder for myself, so here were go.

Filed under: DevOps Continue reading
30Mar/133

Ansible playbook YAML “one flag per line” syntax

Screen Shot 2013-03-30 at 6.07.36 PM

I've started playing around with Ansible for Command Orchestration and Config Management and so far so good. Since I was not happy with having all the module flags in one line in my playbooks I looked for a way to break them into multiple lines.

Since Ansible playbooks are written in YAML one google search later I was on my way, here is how it works at this point, or at least according to my testing using Ansible 1.1 on a CentOS 6.3 box.

---
- name: "creating a config file from a rendered template"
  template: >
           src=/some/path/foobar.j2
           dest=/some/pathfoobar.conf
           owner=root
           group=wheel
           mode=0777

is equivalent to

---
- name: "creating a config file from a rendered template"
  template: src=/some/path/foobar.j2 dest=/some/pathfoobar.conf owner=root group=wheel mode=0777
Filed under: DevOps 3 Comments