5 ms·
For anyone wondering what Ansible is, or what is allows you to do, here's a basic overview screencast I put together [1]. Cannot recommend it enough, as the bar
by WestCoastJustin 12y ago
For anyone wondering what Ansible is, or what is allows you to do, here's a basic overview screencast I put together [1]. Cannot recommend it enough, as the barrier to entry is simply so small, that you can get up and running in no time. The 250+ built in modules are also a killer feature, no hunting around for added logic to make things "just work" off the starting line. I kind of think Ansible hit a sweet spot, coming to market after Puppet/Chef, in that they learned from the ecosystem, and adapted their tool for the pain points. There is also no reason you could not use Puppet with Ansible (rolling upgrades, quick patches, etc).
Happy to answer any questions too.
PS. Bit of a disclaimer: The screencast is a four part series, the first episode is free, and the remain three parts require a subscription. Did not want to bait and switch you. The first episode will give you enough to know what Ansible is all about though.
[1] https://sysadmincasts.com/episodes/43-19-minutes-with-ansible-part-1-4 https://sysadmincasts.com/episodes/43-19-minutes-with-ansibl...
- smegel 12y agoIf you are an Ansible dev, I actually do have a question. I am a bit stumped as to how to "call" a role from other roles with different variables, so as to deploy the same template with different parameters. Currently I am putting the template in a separate role (with a task to deploy it), and then including it several times from other roles, e.g. # role X - include: ../../common/tasks/foo.yml # deploys ../../common/templates/my.conf.j2 - vars: x=33 # role Y - include: ../../common/tasks/foo.yml # deploys ../../common/templates/my.conf.j2 - vars: x=42 Is there a better way to do this? It would be nice to be able to "call" a role/task with parameters, to be able to reuse common elements like templates and task logic.
- BadassFractal 12y agoYou can pass parameters to roles: http://docs.ansible.com/playbooks_roles.html#role-dependencies http://docs.ansible.com/playbooks_roles.html#role-dependenci...
- smegel 12y agoI was somewhat aware of dependencies, but they don't really do what I want. I want to be able to execute a role (or task within a role), much like calling a function, that will be executed at the point it is called (dependencies are all executed before the role executes. I may also want to call the "function" multiple times within a role, with different parameters, to, for example, deploy a template several times to different named files. And yes, dependencies can execute roles multiple times, but this is business logic that belongs in the main role file, not in a meta file. And from what I can see, dependencies can only call a role as a whole, not a part (or task) therein. Basically what I have with "include" does exactly what I want, but it would be nice if it was a bit more explicit that I was calling a role component, something like: # Role X - name: deploy conf files callrole: common::deployconf args: name={{ item.name }} val={{ item.val }} with_items: - { name: 'conf1', val: 33 } - { name: 'conf2', val: 42 } Where callrole::conf corresponds to roles/common/tasks/deployconf.yml. This might allow for more powerful constructs than is available by simply using include.
- skywhopper 12y agoIIRC, they specifically removed this functionality a few versions ago. Their stated reasoning was never clear to me. Something about a lack of clarity regarding which variables passed through how. It might be possible to write a plugin of some sort that adds the functionality you want.
- deleted 12y ago[deleted]
- WestCoastJustin 12y agoI am not a Ansible dev, so take what I say with a grain of salt.. but BadassFractal has a good suggestion re: pass parameters to roles! Also, there is nothing wrong with what you are doing, especially if these values don't change very often. My rule of thumb is to, go with whatever makes it easier to read / understand, and removes the magic. Are you going to figure out how vars x,y are set at 3am for a troubleshooting session.