diff --git a/playbooks/playlet-test.yml b/playbooks/playlet-test.yml new file mode 100644 index 0000000000..78a872a8bc --- /dev/null +++ b/playbooks/playlet-test.yml @@ -0,0 +1,21 @@ +# requires --extra-vars="target='host1;host2;group etc' + +- name: run a playley + hosts: $target + user: root + gather_facts: false + vars_files: + - /srv/web/infra/ansible/vars/global.yml + - $private/vars.yml + + tasks: + - name: populate my target group + action: add_host groupname=parent_group hostname=$item + with_items: $hosts + +- include: $basedir/playlets/test/book.yml + + + + + diff --git a/playlets/README b/playlets/README new file mode 100644 index 0000000000..47808aa55b --- /dev/null +++ b/playlets/README @@ -0,0 +1,36 @@ +playlets are self-contained playbooks which are never intended to be +directly executed. They are only to be used as an 'include' from our other +playbooks. + +All of these playbooks must have: + + +hosts: $parent_group + +the general structure is: + +playlet_name/ + vars/vars.yml + files/myfile.conf + myfile2.conf.j2 + handlers/handlers.yml + book.yml + + + + +template for book.yml +--- +- name: give the play let a name + hosts: $parent_group + tags: + - playlet_tag_name + vars_files: + - vars/somefile.yml + + tasks: + - name: my task + action: stuff which I do + + + \ No newline at end of file diff --git a/playlets/test/book.yml b/playlets/test/book.yml new file mode 100644 index 0000000000..2e7ba81d96 --- /dev/null +++ b/playlets/test/book.yml @@ -0,0 +1,12 @@ +--- +- name: test playlet + hosts: parent_group + tags: + - playlet_tag_name + vars_files: + - vars/vars.yml + + tasks: + - name: my task 1 + action: copy src=files/${myfile} dest=/tmp/${myfile}.txt + diff --git a/playlets/test/files/foo b/playlets/test/files/foo new file mode 100644 index 0000000000..4f41d26438 --- /dev/null +++ b/playlets/test/files/foo @@ -0,0 +1,2 @@ +this is foo +it should end up in /tmp diff --git a/playlets/test/vars/vars.yml b/playlets/test/vars/vars.yml new file mode 100644 index 0000000000..fb4b5f0414 --- /dev/null +++ b/playlets/test/vars/vars.yml @@ -0,0 +1,2 @@ +--- +myfile: foo