7 ms·
Man, I am really happy that playbook parsing and error reporting has been improved. Almost all the frustrations I have had with ansible haven't been from indiv
by herge 11y ago
Man, I am really happy that playbook parsing and error reporting has been improved.
Almost all the frustrations I have had with ansible haven't been from individual modules, but from the mini-language in playbooks defining what modules gets run when with what input variables. Almost pushed me to do away with playbooks entirely and just call ansible modules from a python script directly.
- davexunit 11y agoAnsible would be much better if they just used Python for the playbook API instead of YAML. Ansible would be a clear win over over-engineered competitors like Chef if they fixed this, but as-is I don't want to use it.
- daveguy 11y agoUsing python as the playbook API sounds dangerous. I think the idea is to restrict playbooks so they can be sanitized. To me, it still seems like a win compared to over-engineered solutions like chef.
- davexunit 11y agoI see absolutely no point in this. Code is data, and data is code. Why are Ansible users so eager to cripple themselves? Do you know that some people use jinja2 templates to generate their YAML playbooks? Do you know what could have helped them? A real programming language.
- moises_silva 11y agoPower comes at the price of complexity. If you want to write your playbooks in lisp, ansible is not the way to go.
- rrauenza 11y agoThis was posted on hacker news sometime ago, https://news.ycombinator.com/item?id=10567408 https://news.ycombinator.com/item?id=10567408 -> http://lukeplant.me.uk/blog/posts/less-powerful-languages/ http://lukeplant.me.uk/blog/posts/less-powerful-languages/ I think it is relevant to this discussion. Having used Puppet before ansible, I tend to agree with it.
- crdoconnor 11y agoThe point is that it's not turing complete. Thus it's more readable, less susceptible to technical debt and less susceptible to bugs and always by definition, declarative. Turing complete code turns into an unreadable mess far more easily.
- wstrange 11y agoBut isn't in fact Turing complete? It has variables, control structures, loops and exceptions.
- jzd 11y agoThat does not make it Turing complete. "You need some form of dynamic allocation construct (malloc ornew or cons will do) and either recursive functions or some other way of writing an infinite loop. If you have those and can do anything at all interesting, you're almost certainly Turing-complete." -- http://stackoverflow.com/a/449170 http://stackoverflow.com/a/449170
- wstrange 11y agoThere is a do-until loop: https://docs.ansible.com/ansible/playbooks_loops.html#id22 https://docs.ansible.com/ansible/playbooks_loops.html#id22 Which satisfies the infinite loop issue. Have not looked carefully at the dynamic allocation, but I am guessing (hand waving here....) that it could be accomplished.
- Lazare 11y agoI see your viewpoint, but I personally feel that YAML is a much better solution. I don't want to run arbitrary code in my playbooks! I just want to be able to trigger ansible modules. Besides, it's really easy to write your own Ansible module (in Python), which seems to solve the issue for any use case I can think of?
- davexunit 11y agoYou've never wanted to do something as simple as map over a list in your configuration to handle repetition?
- Spivak 11y agoYou're talking about eliminating duplicates in a list right? my_list | unique I think this is what you're looking for. Any transformation of data that can't be done with the standard filters can be done with a simple filter plugin written in python.
- davexunit 11y ago>You're talking about eliminating duplicates in a list right? No, I'm talking about any atbitrary list processing operation. Some combination of map, fold, and filter, for example. So, in order to do that in an Ansible playbook, I need to write a Python function to do it and use it in the YAML file as a filter because the DSL isn't expressive enough to do it on its own. So... why wouldn't I want to just use Python again?
- hakutsuru 11y agoI feel as though I do process lists via ansible. You could be less abstract and provide code. Otherwise, it is hard to take this complaint seriously. Here we install Jenkins jobs.... - name: create the job config.xml files sudo: true template: src={{ item }} dest={{ conf_jenkins_home }}/jobs/{{ item | basename | replace(".xml.j2", "") }}/config.xml owner=jenkins group=jenkins mode=0600 with_fileglob: - ../templates/jobs/* notify: restart Jenkins And install SonarQube plugins... - name: install sonar plugins sudo: true get_url: url={{ item.value.url }} dest=/opt/sonarqube/extensions/plugins owner={{ ansible_ssh_user }} group={{ ansible_ssh_user }} mode=0755 with_dict: "{{ sonarqube_plugins }}"
- herge 11y agoIt's not the yaml part per se, which is easy to write, it's their weird mini-language they've encoded in yaml, with different vars coming from different places in different conditions. Have to say that things are a lot better than when they weren't consistently using jinja2 to parse the strings.
- gh02t 11y agoIndeed I always liked Ansible, but the input format does occassionally get a little awkward. They've basically designed their own simple language semantically, but they constrained it to be expressed with the syntax of a data serialization language. I think the choice of YAML is because Ansible is supposed to be declarative and a serialization format makes sense there, but some of the "metaprogramming" features they've layered on top like loops can feel a bit strange. Like I said I still like it, but I do feel occasionally that it might be nice to have another frontend that is more like a proper programming language.
- AaronBBrown 11y agoin what way is Chef over-engineered?
- davexunit 11y agoHere's one select example: https://docs.chef.io/attributes.html#attribute-precedence https://docs.chef.io/attributes.html#attribute-precedence There's plenty of this stuff all over.
- AaronBBrown 11y agoIn what way is attribute precedence over-engineered? You can ignore most of it for most cases and just use default for everything, but when you need it, it's there for you. I don't see how it's more or less simple than what Ansible has defined: http://docs.ansible.com/ansible/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable http://docs.ansible.com/ansible/playbooks_variables.html#var.... I count 16 precedence rules in Ansible 2.0. Every time a new configuration management utility comes out, everyone loves it because of it's simplicity or some arbitrary measure of "lightweight," but once Systems Engineers need to solve real automation problems in the real world, they start adopting features to work around the illusion of being "lightweight." I like Ansible for automating my home network where I have simple problems and no need for environment separation. For professional work, I stick with Chef or Puppet.
- sdegutis 11y agoIt's got a lot of complex rules to memorize, which aren't exactly intuitive either.
- deleted 11y ago[deleted]
- fletchowns 11y agoI don't think that's a very good example. Attribute precedence is easy to understand, and it's very necessary. After working with it for a bit it becomes very intuitive.
- jdipierro 11y agoHave you looked into SaltStack at all? The default is to write states in YAML+Jinja but you can change it to use pure python, or a PyObjects renderer that gives it a very pythonic API.
- gerbilly 11y agoI think the reason they didn't use a procedural language is because they specifically wanted to keep the playbooks declarative. Ideally, the playbook should describe the state you want the system to be in. This is 'almost' the case for most modules and I think this was a very good design decision. Having said that, the ghastly YAML format was almost a deal-breaker for me too.
- davexunit 11y agoUsing a real programming language doesn't preclude a declarative programming style.
- moises_silva 11y agoNo, but using a 'real' programming language doesn't force you to write in a declarative style unless you use something like a pure functional language and before you know it people would start making a mess in their playbooks using the whole power of Python. Ansible is awesome for devops precisely because it restricts what you can do and forces you to try to do things in a consistent declarative (and hence idempotent) style, which is important to devops. [edit: fix broken english]
- lenkite 11y agoThis could have been solved by choosing a language like lua and restricting the runtime environment - which is what is done in game software. Lua also has a tight, efficient interpreter. Making a mini-programming language in YAML is _coding horror_.
- Florin_Andrei 11y ago> the playbook should describe the state you want the system to be in This is the real reason. The playbook is the final state. How it gets there is of no interest to you. All you need to be concerned with is the final result - the state described by the playbook. All the extra complexity is handled by the software.
- stevekemp 11y agoYou mighh be interested in looking at fabric in that case - similar idea of running commands over SSH via python. The downside is that it isn't as fully-featured because you have to write the primitives yourself, but it does allow you to write simple recipes with ease.
- bryanlarsen 11y agoI hate ansible and swear at it regularly. That bastardized YAML syntax is the main reason. Unfortunately, it's still better than everything else I've tried.