From 2e1b59a9d2440be500cbb73117ffcf60a5bc137b Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Tue, 13 Mar 2012 19:27:13 -0400 Subject: [PATCH] restructure the examples directory --- examples/{hosts => etc_ansible_hosts} | 0 .../{ => playbooks/handlers}/handlers.yml | 0 examples/{ => playbooks}/playbook.yml | 4 +-- examples/{ => playbooks}/playbook2.yml | 8 +++--- examples/playbooks/playbook3.yml | 26 +++++++++++++++++++ examples/{ => playbooks/tasks}/base.yml | 0 examples/{ => playbooks/templates}/foo.j2 | 0 .../{ => playbooks/vars}/external_vars.yml | 0 examples/{ => scripts}/uptime.py | 0 9 files changed, 32 insertions(+), 6 deletions(-) rename examples/{hosts => etc_ansible_hosts} (100%) rename examples/{ => playbooks/handlers}/handlers.yml (100%) rename examples/{ => playbooks}/playbook.yml (94%) rename examples/{ => playbooks}/playbook2.yml (95%) create mode 100644 examples/playbooks/playbook3.yml rename examples/{ => playbooks/tasks}/base.yml (100%) rename examples/{ => playbooks/templates}/foo.j2 (100%) rename examples/{ => playbooks/vars}/external_vars.yml (100%) rename examples/{ => scripts}/uptime.py (100%) diff --git a/examples/hosts b/examples/etc_ansible_hosts similarity index 100% rename from examples/hosts rename to examples/etc_ansible_hosts diff --git a/examples/handlers.yml b/examples/playbooks/handlers/handlers.yml similarity index 100% rename from examples/handlers.yml rename to examples/playbooks/handlers/handlers.yml diff --git a/examples/playbook.yml b/examples/playbooks/playbook.yml similarity index 94% rename from examples/playbook.yml rename to examples/playbooks/playbook.yml index be5a90d5749..34fd9603dd0 100644 --- a/examples/playbook.yml +++ b/examples/playbooks/playbook.yml @@ -42,7 +42,7 @@ # end of the playbook run - name: write some_random_foo configuration - action: template src=foo.j2 dest=/etc/some_random_foo.conf + action: template src=templates/foo.j2 dest=/etc/some_random_foo.conf notify: - restart apache @@ -66,6 +66,6 @@ # is changed, and only then - name: restart apache - action: service httpd state=restarted + action: service name=httpd state=restarted diff --git a/examples/playbook2.yml b/examples/playbooks/playbook2.yml similarity index 95% rename from examples/playbook2.yml rename to examples/playbooks/playbook2.yml index 3aea97026dc..0eab7b185b0 100644 --- a/examples/playbook2.yml +++ b/examples/playbooks/playbook2.yml @@ -16,7 +16,7 @@ # files but still keep the playbook in public source control vars_files: - - external_vars.yml + - vars/external_vars.yml # as with before, every play has a list of tasks in it @@ -30,7 +30,7 @@ # or we can promote reuse and simplicity by including tasks # from other files, for instance, to reuse common tasks - - include: base.yml + - include: tasks/base.yml # we could also have done something like: # - include: wordpress.yml user=timmy @@ -44,7 +44,7 @@ # and simpler recipes, you may wish to only have one # handler file for all your plays and playbooks - - include: handlers.yml + - include: handlers/handlers.yml # you can mix things that are directly in the file with things # that are included. Order is executed as written, but only @@ -75,7 +75,7 @@ vars: release: 2.0 vars_files: - - external_vars.yml + - vars/external_vars.yml # these all runs as the user 'mdehaan'. If there were any handlers diff --git a/examples/playbooks/playbook3.yml b/examples/playbooks/playbook3.yml new file mode 100644 index 00000000000..092b5997c70 --- /dev/null +++ b/examples/playbooks/playbook3.yml @@ -0,0 +1,26 @@ +--- +# this is not so much an example playbook file as a playbook we sometimes use +# for testing. I have chosen to not comment this one so folks can get +# an idea of what a concise playbook can look like... + +- hosts: all + user: root + vars: + http_port: 80 + max_clients: 200 + tasks: + - name: simulate long running op, wait for 45s, poll every 5 + action: command /bin/sleep 15 + async: 45 + poll: 5 + - include: tasks/base.yml favcolor=blue + - name: write the foo config file using vars set above + action: template src=foo.j2 dest=/etc/some_random_foo.conf + notify: + - restart apache + - name: ensure apache is running + action: service name=httpd state=started + - name: pointless test action + action: command /bin/echo {{ http_port }} + handlers: + - include: handlers/handlers.yml diff --git a/examples/base.yml b/examples/playbooks/tasks/base.yml similarity index 100% rename from examples/base.yml rename to examples/playbooks/tasks/base.yml diff --git a/examples/foo.j2 b/examples/playbooks/templates/foo.j2 similarity index 100% rename from examples/foo.j2 rename to examples/playbooks/templates/foo.j2 diff --git a/examples/external_vars.yml b/examples/playbooks/vars/external_vars.yml similarity index 100% rename from examples/external_vars.yml rename to examples/playbooks/vars/external_vars.yml diff --git a/examples/uptime.py b/examples/scripts/uptime.py similarity index 100% rename from examples/uptime.py rename to examples/scripts/uptime.py