Jump to content

Search for Ansible modules


Recommended Posts

An Alfred workflow to search the Ansible module documentation.

alfred_ansible.png.f4c3ddfb49bf5c189b99a6f50846bc85.png


Requirements

As macOS still ships Python 2 which is no longer supported since January 1st, 2020 - Python 3 is required to be installed. Due to the usage of f-strings at least Python 3.6 is required. The workflow uses the Python 3 interpreter returned by

/usr/bin/env python3

 so the installation method won't matter. However, i do recommend the usage of homebrew. The CI tests on github cover python version up from 3.6.

 

Required modules can be installed using pip:

/usr/bin/env python3 -m pip install -r requirements.txt

 

Installation

You can either download the workflow from Packal or the release page of the github repository


Usage

The workflow is triggered using the keyword ansible and will use the following input as search parameters.

 

alfred_ansible_usage.png.a58f267e900afb64581a4957dbc2f2b9.png

 

Pressing enter on any of the results will open the corresponding documentation page in the default browser.

 

alfred_ansible_browser.thumb.png.a4a68187ff707ce3c0c7a11c5e3a3964.png

Edited by abyth
Added packal url
Link to post
5 hours ago, abyth said:

The workflow uses the Python 3 interpreter returned by

 

You’ve actually hardcoded /usr/local/bin/python3:

 

query=$1

/usr/local/bin/python3 ansible.py ${query}

 

FWIW, there’s little point in using /usr/bin/env in a workflow. Mac apps don’t use your shell environment, so /usr/bin/env python3 is basically always going to be /usr/bin/python3.

Link to post
21 hours ago, deanishe said:

 

You’ve actually hardcoded /usr/local/bin/python3:

 


query=$1

/usr/local/bin/python3 ansible.py ${query}

 

FWIW, there’s little point in using /usr/bin/env in a workflow. Mac apps don’t use your shell environment, so /usr/bin/env python3 is basically always going to be /usr/bin/python3.

My bad..  must have happened while testing different launch options. Is there a common best practice for that? 

Link to post
42 minutes ago, abyth said:

Is there a common best practice for that?

 

For workflows? If you’re going to release it, today I’d recommend hardcoding /usr/bin/python3 and calling it “Catalina and later only”.

 

Perhaps use

export PATH=/bin:/usr/bin:/usr/local/bin
python3 myscript.py "$1"

to allow it to fall back to a Homebrew Python 3 on older OSes.

 

I’m generally a fan of hardcoding the system version of Python, so you know what you’re going to get. You never know what other people have symlinked to /usr/local/bin/python3, and it'll likely be you they ask for help when your workflow doesn't run on some weird, stripped-down Anaconda Python they've installed.

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...