On May 8, 5:12 pm, Michael DeHaan <
michael.deh...@gmail.com> wrote:
> Nice. Very glad to see a complex example. Pretty easy to follow.
Thanks!
> I think we have enough to start that contrib repo of examples (via git submodules, so everybody can host their own stuff) now.
I'm all for it; let me know how to get it going.
> Style wise, I think a line of whitespace between tasks and before/after the line that says "tasks:" is a good idea. I'm personally not a fan of YAML anchors so much, as I see
> that playbooks happen to CURRENTLY be written in YAML, but eventually parsing and implementation are going to be separated out a bit.
Yeah, the anchors are a hack to be able to use a list in both
with_items and templates.
> I don't understand how the anchor and the list and the array are mixed with the anchor here, in particular:
>
> dfs_datanode_data_dir: &datadir
> - /data1/hdfs
> - /data2/hdfs
>
> That first one looks like a hash element, but then it's followed up by two list elements.
Yeah, YAML's a bit weird. dfs_datanode_data_dir is a list of two
items, and &datadir is a pointer to it. Why YAML doesn't just use
*dfs_datanode_data_dir to reference the variable directly, I dunno.
> Organization wise, I think it's clearer to not mix playbooks, templates, and included handlers all in the same directory.
>
> This is how I would have it, if you assume a directory named "playbooks" exists one level up. It would be nice if everyone adopted a similar standard (or proposed a better one), such that
> folks hopping between examples can easily grok each other's content.
>
>
https://github.com/mpdehaan/ansible-examples
That's a good idea, I'll re-organize a bit.
> I would also think install_hadoop would be a pretty minimal playbook with there being an install-hadoop and an install-java in tasks, all included. This promotes applying a playbook
> that says "be this role", rather than having to remember to run 3 playbooks to get things in line. It also means install-java is more or less reusable by other things that need Java (maybe).
Totally agreed. I really wanted to make small chunks of reusable
functionality, so people could re-use playbooks unmodified and just
tweak a vars file. The problem is I have lists of directories that I
need to both create and stuff in a config file template. In order to
loop over the directories using with_items, they have to be in a real
YAML list declared in the same YAML file with an anchor that I can
reference. Support for list variables in with_items would be really
great here.
> Since tasks are intended to be idempotent, it's safe to apply "java" to things that already have Java, too.
>
> See the monitoring.yml in my example about how the playbook is mostly just includes.
My install-java is a bit "opinionated" about which Java to install, so
I didn't want to foist it on everybody. ;) Plus even if an action is
a no-op because of idempotence, it still takes time to run, and my
playbook is already too slow as it is -- install-hadoop does double-
duty as "update-hadoop-config" (because of the aforementioned
limitations), and waiting for yum to run a dozen times with no effect
gets old fast.
Thanks for the feedback.
-John