Install awx-cli, then what?

I’m obviously without a clue here:

bash-4.4# pip3 install --log ~/install2.log awxkit
Requirement already satisfied: awxkit in /home/awx/.local/lib/python3.6/site-packages

Requirement already satisfied: PyYAML in /usr/lib64/python3.6/site-packages (from awxkit)
Requirement already satisfied: requests in /home/awx/.local/lib/python3.6/site-packages (from awxkit)
Requirement already satisfied: idna<3,>=2.5 in /usr/lib/python3.6/site-packages (from requests->awxkit)
Requirement already satisfied: chardet<5,>=3.0.2 in /home/awx/.local/lib/python3.6/site-packages (from requests->awxkit)
Requirement already satisfied: certifi>=2017.4.17 in /home/awx/.local/lib/python3.6/site-packages (from requests->awxkit)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/awx/.local/lib/python3.6/site-packages (from requests->awxkit)
bash-4.4# awx
bash: awx: command not found

Hey Kevin,

Can you share some details of your environment? I’ve given this a shot and it works okay for me:

~ head /etc/os-release -n3
NAME=Fedora
VERSION=“32 (Workstation Edition)”
ID=fedora
~ python3 --version
Python 3.8.5
[yossarian] (fedora:●●) ~ python3 -m venv foo
[yossarian] (fedora:●●) ~ source foo/bin/activate
~ pip install awxkit 2>&1 > /dev/null
~ awx -h
usage: awx [–help] [–version] [–conf.host https://example.awx.org] [–conf.token TEXT] [–conf.username TEXT] [–conf.password TEXT] [-k] [-f {json,yaml,jq,human}] [–filter TEXT] [–conf.color BOOLEAN] [-v] resource …

positional arguments:
resource
login authenticate and retrieve an OAuth2 token
config print current configuration values
import import resources into Tower
export export resources from Tower

Thanks for the question!

bash-4.4# head /etc/os-release -n3
NAME=“CentOS Linux”
VERSION=“8 (Core)”
ID=“centos”

bash-4.4# python3 --version
Python 3.6.8

bash-4.4# awx -h
bash: awx: command not found

The application may be somewhere in my file system, but I don’t know where to start looking for it.

Kevin

Try looking in ~/.local/bin

I’m on fedora 33, which is not too unlike centos8 and thats where my system pip3 installs it.

Maybe your $PATH is not correctly configured to pick up binaries in ~/.local/bin

Bingo! Thank you. Yes, it was in ~/.local/bin, and yes my path was not configured to find it. Great call!

Kevin

For those following along for fun, after getting awx to work, this builds a project-sourced inventory. So much easier than doing it 150 times in the GUI! Thank you to the whole team of people who make this kind of stuff possible!

inventory_name=shared_environment_a
new_inventory=$(awx inventory create --name “$inventory_name” --description ‘Autoimport by awx-cli from OEM’ --organization 3)

I will show the find, though the code works easily from $new_inventory’s json return value

found_inventory=$(awx inventory list --name “$inventory_name”)
found_inventory_id=$(echo $found_inventory | python3 -c “import sys, json; print(json.load(sys.stdin)[‘results’][0][‘id’])”)
awx inventory_sources create --name oem --description ‘Autosourced by awx-cli from OEM’
–source scm
–source_path “ansible/inventory/$inventory_name.yml”
–overwrite true
–overwrite_vars true
–inventory “$found_inventory_id”
–update_on_launch true
–source_project 30
–update_on_project_update false

Thanks for the feedback Kevin :smiley:

Based on your example, you might be interested to know that the CLI generally lets you specify resources (like inventories) using just their name (assuming you keep them unique across e.g., Organizations). Try --inventory $inventory_name and see if you can skip the ID lookup. The same is true for --organization “Some Organization Name”

you can skip the ID lookup
Good to know! Thank you, again, Ryan.

Kevin

Great news!

I noticed this on Debian 10/11 too, where awxkit will install okay but you can’t find it in your path. Would be nice if it worked without having to specify the full path to awxkit.