Announcing the AWX CLI

Hey everyone,

As part of our recent AWX 7.0.0 release, we’re pleased to announce that we’ve released a new official AWX command line interface.

We recently started an initiative to come up with an official community-supported alternative to the open source https://github.com/ansible/tower-cli/ library some of you may be familiar with.

While tower-cli has served many of you well, it has some technical limitations which have made it cumbersome to maintain and add support to as AWX has grown.

The new AWX CLI in 7.0.0 is intended as a spiritual successor (if you’ve used tower-cli in the past, you’ll find this new interface familiar), and is a tool that we intend to test and maintain as AWX changes.

We’d love for you to try it out - installing it and generating its documentation is relatively simple using the instructions at:

https://github.com/ansible/awx/tree/devel/awxkit/awxkit/cli/docs

If you have feedback, please share it here, and please file any bugs (or enhancement requests) you discover at the official issue tracker: https://github.com/ansible/awx/issues/new/

Happy Automating!

Hello Ryan,

I’m trying to download awxkit for 1.0.6.15 (yes it’s an old version!) but I can’t…

https://github.com/ansible/awx/archive/1.0.6.15.tar.gz#egg=awxkit&subdirectory=awxkit
ERROR: HTTP error 404 while getting https://github.com/ansible/awx/archive/1.0.6.15.tar.gz#egg=awxkit&subdirectory=awxkit

Hey Cédric,

The new CLI is available starting in 7.0.0, is you’ll want to download using this link:

https://github.com/ansible/awx/archive/7.0.0.tar.gz#egg=awxkit&subdirectory=awxkit

ho ok, I misunderstood, I thought that we could adapt it to older versions of AWX.

Thanks :)

hi my interest is given this announcement, does tower-cli support awx 7 ? and at what point will it be dropped entirely ?

barry kelliher (whynotnowtoday@gmail.com) said:

hi my interest is given this announcement, does tower-cli support awx 7
? and at what point will it be dropped entirely ?

tower-cli supports AWX 7 to the extent that the APIs it uses are the same
as when features were added to tower-cli; this means for most basic operations
it should work OK. New functionality in AWX 6 or AWX 7 may not be supported in
tower-cli, and we do not have plans to add it.

Bill

For docker awx installs do you install this on the awx_web or awx_task container. I assume you don’t install it on the server hosting the docker containers.

Thanks

So I’m trying to make use of this, and I’m looking for a bit of advice. When I’m boot strapping an AWX system, I need to use the cli for some tasks. Traditionally I’ve written out a tower_cli config file that stores the credentials, so that I’m not adding the credentials to every task execution (and then marking them as no_log to prevent credential leakage). It seems awx cli doesn’t support this and only works via the oauth2 methods. I can either specify the credentials on the command line for every task, or I can get a token and set the token in the ENV. I’m looking for some guidance on bootstrapping that token, via Ansible. I can certainly do a task to get the token output, and then carve up that output to get the actual token bits, but that seems like a bit of a mess. Is there a better way to simply get the token that I can then stash in a file for later reference, or stash in the env of an Ansible play?

Thanks!

Hey Jesse,

The new CLI doesn’t pull credentials from a configuration file like tower-cli, but you can use environment variables*.*

$ TOWER_USERNAME=joe TOWER_PASSWORD=secret awx login

while this works, it prints out a shell variable, e.g.,

export TOWER_TOKEN=…

You could parse this in Ansible but I agree that’s a little gross. Maybe we should change the default behavior here to better match expectations?

Jesse,

Would this help? https://github.com/ansible/awx/pull/4854

Could also try pulling the token directly from your AWX instance and store that in an env var /file for later. Maybe even after the play completes you could expire the token. Sample snippet:

`

  • name: Create a personal access token with read/write scope
    uri:
    method: POST
    url: https://awx.com/api/v2/users/1/personal_tokens/
    user: “{{ username }}”
    password: “{{ password }}”
    force_basic_auth: yes
    body_format: json
    body: {“description”: “AWXKit Token”, “scope”: “{{ mode }}”}
    status_code: 201
    register: post_result
    no_log: true

  • name: Store token into variable ‘oauth2_token’
    set_fact:
    awx_oauth2_token: “{{ post_result.json.token }}”
    no_log: true
    `

I replied in the issue, but I believe that would be great!

Uriel,

For what it’s worth, this is basically what the awx login command does under the hood: https://github.com/ansible/awx/blob/devel/awxkit/awxkit/api/pages/base.py#L175