Project Wisdom for Red Hat Ansible
research.ibm.com
research.ibm.com
But it won't matter, since our benevolent robotic AI overlords will create them for you, the certified IBM Project Wisdom(TM) Prompt Engineer, dual-classed to Tech-Priest (but without any Warp to go mad in - that, you will have IT for).
> Project Wisdom will be able to read plain English entered by a user, and then generate automation content written in the Ansible syntax: Ansible Playbooks and Ansible Roles.
Do Ansible users really want to input plain English? I would not even know how to say what I need: "make sure journald is persistent, up to 1GB, then install zsh with my laptop config if it's in a laptop group..." That's awfully imprecise. Nobody wants to program in plain English. And the more technical the task, the less suitable plain English becomes.
And even worse: the goal is to convert plain English into yaml "code", mostly to "make it easier for beginners to learn Ansible". I think it is not helpful at all to throw blocks of generated code to a beginner.
People have wanted that since at least as long as cobol has been a thing.
That's likely because the training data is Ansible Galaxy, and the vast majority of existing code doesn't use FQCNs. I still prefer not to, since it adds visual clutter to the playbook (not to mention a tiny bit of extra typing even with autocomplete), and playbooks work exactly the same 99.999% of the time.
Someone mentioned they were considering adding more lint-friendly inputs into the model, but as with all things AI, the way it's done could badly affect the output, too.
I still don't feel like there's a ton of value from any AI-driven code completion tools... writing out code (especially the initial bit) is often the first 1% of work when venturing out into new programming or automation work.
IBM nerfed Ansible when they pulled the community packages off it and made them a paid premium in their Red Hat Enterprise Linux. ansible-core, as they call it, is like a shaved cat: newcomers are going to find it offensive whilst veteran cat enjoyers are going to call it out for what it is and shame you for the misplaced effort with a set of shears while they download the EPEL fur you tucked under the couch cushions.
The reason we did ansible is because we dont have a good product that competes with Github...either that or the tech writing team is particularly bad this year after the recession cuts.
Ansible was split into Ansible Core and the separate collections to separate the lifecycle of collections from Ansible itself. It was not a nerfing of Ansible by IBM. You as an admin get to pick which collections and which versions of said collections fit your needs best, rather than having to wait for new Ansible versions to be released. This is the same argument developers have in programming languages about standard libraries, you can either have a relatively large one (Python) that changes slowly, or a small one (Rust) where libraries are offloaded to the ecosystem and nobody can agree on what's best.
In RHEL, Ansible Core is only provided (in the support sense) for the use with RHEL System Roles (upstream: linux-system-roles). It still provides all the same pieces to do normal Ansible administration workloads. You don't need the EPEL Ansible package unless you want the massive standard library. Full Ansible support is provided by Ansible Automation Platform subscriptions.
I'm interested to see how this works out because unlike Copilot where you're "merely" writing pieces of regular code, Ansible is uniquely in a position to trash your entire network and operations, making correct operation absolutely essential. The stakes seem very high to me.
(Disclosure: I work for Red Hat which was acquired by IBM, but not on anything related to this)
Anytime I would typically be reaching for a shell script of medium to long length, it's typically easier to maintain in Ansible.
But, if I find my Ansible is getting rather long, I need to do things more complicated than simple loops, or there isn't an Ansible primitive to interact with the system I'm working with... time to start reaching for an actual programming language like Python or Go.
I gravitated to Ansible because it was language independent, simple to translate line-by-line scripts and didn't require an on server agent to work. Knowing that I could invest into Ansible and take it with me anywhere that I had SSH access was very motivating.
It's not perfect, but it's so much better than my previous experiences that I won't complain about the pain points too loudly.
- create virtual env
- activate and install pip packages
- run command using that environment
I don't have a copy of any of our playbooks on this as I'm at home and it's late. But it's basically just a couple of tasks.
Check out `ansible.builtin.pip` to setup and install the virtualenv and then just call `ansible.builtin.command` to run it explicitly. Implicit use of the venv can be accomplished via common task argument `env` which also lets one fiddle with PATH.
What?
Instead, we get a terrible dsl baked in a bad markup language that is hard to write, painful to debug and impossible to maintain.
That you have to come up with concepts like an inventory, fact and magic variables should have been your first clue that they were reinventing badly what any language ecosystems provides for free.
And the worst is, ansible is probably one if the best deployment systems at our disposal.
My biggest complaint with Ansible is the execution aspect. The fact that mitogen hasn't become the standard strategy plugin and instead Ansible still opens an SSH connection per task is nuts.
Just as a random example, for complex group structures you have to know/remember that although Ansible allows nesting groups, groups are actually a flat structure. If you have prod.webservers and uat.webservers, the 'webservers' group will include members of both.
That's not hard to work around, but it can easily lead to situations where you end up deploying to prod even though you only intended to deploy to UAT.
Variables are kind of a mess too. Assuming the docs are authoritative, there are 22 different places that variables can come from and which one is used will depend on the precedence. At some point, a 'switch' or series of 'if-elif' statements start to sound much simpler.
[1] https://docs.ansible.com/ansible/latest/reference_appendices...
Do you know if this behavior can be enabled per-role, or even better, per-task?
Large Ansible code bases are painful to maintain. Roles don’t encapsulate well enough and the setting that makes their variables private is unusable if you need to “exports”/“outputs” and I guarantee you do, flow control isn’t powerful enough and you either supplement by dropping down to script/shell or by wring whole programs in Jinja, variables are so spooky action at a distance that you need an external tool to graph where they come from, vault variables aren’t greppable so good luck there, you can’t write a type checker because it’s all strings and any large codebase will dynamically generate variable names due to lack of expressiveness, you will desperately want a way to tell Ansible to eagerly evaluate some variables instead of keeping them as strings and find out how ugly the workaround is without your own patches, you eventually desperately wish you had the ability to evaluate filters and lookups on the target and might eventually, like me, write a plug-in for that. Your options for complex data transformations is writing 50 line filter pipelines with item.0 item.1 or dropping to python and just writing your own filter, you will also eventually desperately wish you could define new modules via “subroutines” by chaining a few trivial module invocations together and then find out that you must drop to an action plugins which expose all the underbelly of Ansible. You will pull your hair out getting Jinja to strip the whitespace from strings to get Ansible to recognize the results as an array since it’s all strings, you will find out that Ansible has its own string type that doesn’t play nice with str and that is somehow exposed to you in bog standard Ansible.
If Ansible was a Python library I would scream for joy at how much unnecessary complexity and necessary bullshit trivia I could drop from my brain.
> and instead Ansible still opens an SSH connection per task is nuts
Mitogen is not worth the bugs compared to using SSH ControlPersist.
I have a SSH hook that sends a chat message whenever someone SSHs into a server, and Ansible without mitogen floods these, even with ControlPersist.
If you have it working, can you share your ansible.cfg?
I do get the annoyance of your script though.
Many languages totally support declarative idioms out of the box (like you mention), there's no need to reinvent anything here.
In particular I'm a big fan of AWS CDK, although it only works for AWS. (Yes, I know about CDKTF, but it's buggy alpha software).
Fully wholeheartedly agree but, as I stated in previous ocasions in this site, after the nightmares I've seen people, in many different places, doing with a high level tool like Ansible (and also Terraform), I apply heuristics about the probable outcome of every DevOps using a proper Turing-complete language as a general trend and I just want to leave CS and buy a hut in the middle of nowhere. Perhaps something like that must come after a shift in the mentality of the whole business where people in CS in general, assumes one needs to be a good coder, no matter if you do DevOps of software and therefore, learn about software design patterns, reusability and best coding practices.
You have to already be a good coder to write Ansible but you have all your limbs tied behind your back because you get none of the features of Python to help you reign in complexity and validate correctness.
it's like the dumbness of Ansible is really the main feature it has.
It's not perfect, I still feel like I'm dropping down to just hitting `server.shell` a bunch , but at least as a programmer first, it feels more comfortable vs the mountains of yaml (and doc searching) for Ansible.
On the whole it's a less frustrating experience. I still have a vague feeling that in my case - where each server(s) is generally customised per client and I've never felt comfortable just pointing ansible (or pyinfra) and a configured server and re-running it - that perhaps I would really just be better off with a bunch of shell scripts. I don't generally tear-down and throw-up multiple servers a day, week or even month.
rrconf sort of fills this but works off a bit more infrastructure than I want to manage with its different git repos per action.
You generally want an overarching single source of truth for IT systems. One that defined which parts a system contains and how it is set up. This starts to get important when you want maintainable testing environments, and more so as the number of system integration points grow, but it generally makes tracking changes and having a controlled deployment process so much easier.
So it is natural to start with a declaration of how small pieces fit together. This is Puppet/Ansible where the language is just a list of objects, where each object is implemented in "real" programming language. But the list soon needs logic, if not for other reasons than because testing environments have subtly different requirements, and the list grows into a semi-language.
That's not enough and people new to the system soon feels constrained, why not ditch that domain specific thing and implement the whole thing in the "real" language? This is Chef/Salt. But now all you have is another object, which needs an overarching list of objects, and soon we have another simple description for that.
And then we repeat this all over again.
(There are specific issues for some parts of this, which is not part of the above story. Ansible didn't have to choose yaml for their domain specific language, they should have seen that coming. But that's not for this story. We instead get to see this repeated again in the container space with templates and Helm charts. Also Jenkins pipelines which slowly mutates to Groovy and back.)
Aka, linting/formattimg for the naming conventions.
I'm so happy I embraced immutable infrastructure. I never needed Ansible anymore.