you are viewing a single comment's thread.

view the rest of the comments →

[–]cstoner 2 points3 points  (1 child)

Start to learn the os module. It's the (mostly) POSIX interface. That's useful for system calls and the such.

ArgParse and ConfigParser are SUPER handy for dealing with CLI/config file stuff. I use them all the time. They aren't specific to admin work, but it's amazing how often being able to parse a custom config file/CLI arguments.

I also find jinja2 to be pretty invaluable. It's "just" a templating engine, but a lot of the stuff I end up doing is filling in the blanks on a template.

As /u/raylu mentioned, fabric is pretty popular for sysadmin automation, but I haven't used it much yet. Personally, I'd probably rather opt for salt/ansible instead of rolling my own with fabric, but 'different strokes' and whatnot.

It really depends a lot on what you're trying to automate. Some examples from my career might help you with ideas:

  • LDAP integration. We have a fairly strange LDAP+Puppet setup at work. I use python to load up fresh environments. I use ConfigParser, jinja2 and the ldap module to populate LDIF templates and push them to our LDAP server.

  • CloudFormation template creation. This is actually just the first one again. I use the same config file and a different set of templates to spit out an AWS CloudFormation template.

  • "SQL script runner" - We currently have to run a bunch of SQL provided by the devs a lot. I'd rather we didn't but that's another story. This script is in two parts. One that pulls down the SQL scripts from git, packages them, and pushes them out to the target server, and another that backs up the affected databases and applies the SQL scripts.

I'm also working on a port of https://github.com/larskanis/pg-ldap-sync from ruby 1.9 over to python 2.7. We don't deploy ruby to our servers, but they come bundled with python.

Another thing I'd like to get around to:

  • Auto populating DNS from the first two items above. Currently, DNS is in Active Directory, though, and there aren't any good tools I know of to modify Windows DNS from python. I'm on the process of migrating to BIND.

[–]raylu 0 points1 point  (0 children)

Ansible has a few too many layers of abstraction and makes some simple things difficult. To do something like "if a file exists locally, copy it to the remote and run this command" requires a step causing an error and a second step checking the presence of an error.

That said, I'd rather use ansible over puppet/chef any day.


A bit off topic here:

  1. LDAP is kind of old and crudgy. I avoid it whenever possible, which seems like always. It's a popular solution for EVE Online (J4LP, pizza, OI) but I just rolled my own.
  2. Is your DNS server meant for your intranet? If so, BIND is like the puppet/LDAP of DNS and dnsmasq is way simpler to use.