Skip to content

Instantly share code, notes, and snippets.

@jorgenschaefer
Created October 8, 2013 21:49
Show Gist options
  • Select an option

  • Save jorgenschaefer/6892401 to your computer and use it in GitHub Desktop.

Select an option

Save jorgenschaefer/6892401 to your computer and use it in GitHub Desktop.
# install_wiki.yml
---
[... other installation stuff, including templates ...]
# The templates etc. use up to 10 different configuration options for
# each wiki. The following only uses the "name" attribute, but it's
# the most complicated one as it involves another with_items loop.
- name: wiki | Install mediawiki files for {{wiki.name}}
file: src=/usr/share/mediawiki/{{item}}
dest=/srv/emcom/{{wiki.name}}/{{item}}
state=link
owner=emcom group=emcom
with_items:
- api.php
- config
- extensions
- img_auth.php
- includes
- index.php
- install-utils.inc
- languages
- maintenance
- opensearch_desc.php
- profileinfo.php
- redirect.php
- redirect.phtml
- skins
- StartProfiler.php
- thumb.php
- trackback.php
- wiki.phtml
# main.yml
- name: emcom | Install wikis
include: install_wiki.yml
with_items:
- name: foowiki
dbname: foowiki
dbuser: foowiki
sitename: FooWiki
scriptpath: /wiki
articlepath: /mediawiki
required_forum_name: Internal
logo: http://.../
server: http://.../
wikipassword: "{{dbpass.foowiki}}"
- ... imagine a handful of other wikis here with different
configuration options ...
# Now, for each iteration, item will be a dictionary with all wiki
# options. I can work around this using something like this:
- name: emcom | Install wikis
include: install_wiki.yml
wiki_name="{{item.name}}" ... all 10 variables ...
# Then I need to rename wiki.name to wiki_name in the
# install_wiki.yml, and have some annoying repetition in main.yml.
# I was wondering if there's a better solution, or if I am approaching
# the problem the wrong way around. :-)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment