Skip to content

Taskfile - The Modern Makefile

Task is a modern version of make written in go. They allow you to use yaml & jinja to define your actions and have the system build things for you. I use them to build an OPs environment and do on boarding. It's a quick and easy way to make sure you have the tools needed to do your job.

Example

version: "3"

tasks:
  hello:
    cmds:
      - echo 'Hello World from Task!'
    silent: true

Here's an example of getting a HPC python and ansible ops environment going

Example

---
version: "3"
vars:
tasks:
  default:
    desc: Install Ops stuff
    depends:
      - pips_needed
      - radssh_install
      - galaxy_needed
 pips_needed:
   desc: Installs python packages needed
   dir: "{{.USER_WORKING_DIR}}"
   cmds: [pip install -U --user -r requirements.txt]
 radssh_install:
   desc: Installs Radssh
   cmds:
     - pip install -U --user paramiko
     - pip install -U --user --use-pep517 git+https://github.com/radssh/radssh.git
 galaxy_needed:
   desc: Installs galaxy collections and roles
   dir: "{{.USER_WORKING_DIR}}"
   cmds: [ansible-galaxy install -r requirements.yml]

While it may look complicated, it's pretty simple. From the top to the bottom it says. When run go-task Taskfile.yml install the default task. The default task depends on the following tasks, pips_needed, radssh_install, galaxy_needed. So it will run those in order to make sure it has everything it needs. The pips_needed task says use the current working directory and run these commands. In this case it's just a single command to pip install the requirements.txt file. The next section uses pip to make sure that paramiko and radssh is installed from github. Lastly the final task, galaxy_needed does the same thing as the first task but with ansible-galaxy rather than pip.

I have Taskfiles created for all of my most commonly used systems from RHEL to MacOS and everything in-between. If you need or want to use them let me know!