From 83c18a42fa544e2857039fd4bc083c3507c742cb Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Fri, 15 Mar 2013 22:22:22 +0000 Subject: [PATCH 1/4] demo playlet - as a trial to work out bugs --- playlets/README | 36 ++++++++++++++++++++++++++++++++++++ playlets/test/book.yml | 12 ++++++++++++ playlets/test/files/foo | 2 ++ playlets/test/vars/vars.yml | 2 ++ 4 files changed, 52 insertions(+) create mode 100644 playlets/README create mode 100644 playlets/test/book.yml create mode 100644 playlets/test/files/foo create mode 100644 playlets/test/vars/vars.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..04a5cd29dc --- /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}.txt 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 From 9d1045491e08d7092be906f089e5d2c4ee9f8773 Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Fri, 15 Mar 2013 22:27:27 +0000 Subject: [PATCH 2/4] test playbook for included playlets/playbooks --- playbooks/playlet-test.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 playbooks/playlet-test.yml 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 + + + + + From 7df08be1fa3b5965da933281cfb3bd47556f8fac Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Fri, 15 Mar 2013 22:46:34 +0000 Subject: [PATCH 3/4] it's not a var - it's a real group, dumbass --- playlets/test/book.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playlets/test/book.yml b/playlets/test/book.yml index 04a5cd29dc..31e265b86a 100644 --- a/playlets/test/book.yml +++ b/playlets/test/book.yml @@ -1,6 +1,6 @@ --- - name: test playlet - hosts: $parent_group + hosts: parent_group tags: - playlet_tag_name vars_files: From 406849dd81385173ae160cacd28050eebf60b4cb Mon Sep 17 00:00:00 2001 From: Seth Vidal Date: Fri, 15 Mar 2013 22:47:59 +0000 Subject: [PATCH 4/4] right path --- playlets/test/book.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playlets/test/book.yml b/playlets/test/book.yml index 31e265b86a..2e7ba81d96 100644 --- a/playlets/test/book.yml +++ b/playlets/test/book.yml @@ -8,5 +8,5 @@ tasks: - name: my task 1 - action: copy src=files/${myfile}.txt dest=/tmp/${myfile}.txt + action: copy src=files/${myfile} dest=/tmp/${myfile}.txt