119 Commits

Author SHA1 Message Date
Ryan Petrello
c373d5307f
allow the CLI to associate Galaxy credentials to Organizations
$ awx organizations associate Default --galaxy_credential "Ansible Galaxy"
2020-10-21 09:39:33 -04:00
Ryan Petrello
0cdcbdfea6
fix a confusing error message when extra vars aren't valid JSON/YAML
see: https://github.com/ansible/awx/issues/8359
2020-10-12 12:56:13 -04:00
Aggelos Kolaitis
9918b2581c
Support !import and !include in awx import -f yaml command 2020-09-13 17:01:12 +03:00
Ryan Petrello
815d691622
clean up old authtoken support
just use Bearer tokens - those are the only type of tokens we support
2020-08-19 12:23:00 -04:00
Ryan Petrello
987c7d48a0
minor cleanup up CLI import -f yaml support 2020-08-11 09:44:13 -04:00
Rigel Di Scala
579604d2c6 Allow YAML as a CLI import format
This changset allows the import of YAML formatted resources. The CLI
user can indicate which format to use with the `-f, --format` option.
The CLI help text has been amended to reflect the new feature.

The AWX CLI `export` subcommand offers the option of formatting the output
as YAML or JSON, so it makes sense that the `import` subcommand reflects
this.

A simple test is also provided. In order to ease the task of testing
commands that import resources by reading the stdin, the CLI has been
extended to allow specifying an alternative file descriptor for stdin,
similarly to stdout and stderr.
2020-08-10 23:43:53 +02:00
Rigel Di Scala
490746fe8c
Fix garbage being printed when exporting as YAML - related #7795
This resolves issue #7795, by passing the `encoding` keyword argument
only when the code is run on a Python 2 interpreter.

related #7795.
2020-08-03 11:57:45 -04:00
Graham Mainwaring
29da0abfc1 Don't traceback on KeyboardInterrupt 2020-06-23 16:14:02 -04:00
Jeff Bradberry
393369adec First cut at examples of the import and export commands 2020-06-18 15:32:49 -04:00
Jeff Bradberry
3860c7597f Move the import logic into methods on the ApiV2 class 2020-06-09 13:54:05 -04:00
Jeff Bradberry
e4146e9bc7 Move the export logic onto methods on the ApiV2 class
making it easier to invoke programmatically.
2020-06-09 13:54:05 -04:00
Jeff Bradberry
19c92a7055 Enable notification templates 2020-06-09 13:54:05 -04:00
Jeff Bradberry
6a9add4fe3 Deal somewhat reasonably with missing fields as part of the natural key
- JobTemplate.organization has recently been added, we need to support
  with and without
- WorkflowJobTemplateNode is shortly going to get an identifier field,
  and we will need to support both with and without
2020-06-09 13:54:05 -04:00
Jeff Bradberry
ad574eb896 Enable credential export 2020-06-09 13:54:05 -04:00
Jeff Bradberry
55f79a4569 Fix a couple of flaws
- The dependency ordering may spit out page types that weren't in the import data set.  Make sure to be able to map those to resources anyway.
- freeze() needs to be able to deal with nullable foreign keys.
2020-06-09 13:54:05 -04:00
Jeff Bradberry
d20fa03034 Create new Import.dependent_resources method
that yields up resource names, even ones that aren't explicitly in the
import data, in dependency order.
2020-06-09 13:54:05 -04:00
Jeff Bradberry
868aafb263 Filter out managed credential types
since we cannot patch them upon import.
2020-06-09 13:54:05 -04:00
Jeff Bradberry
3f204659a8 Temporarily disable export of resources that may not work yet 2020-06-09 13:54:05 -04:00
Jeff Bradberry
ea5b810e87 Sort the asset groups to be imported by their dependency relationships 2020-06-09 13:54:04 -04:00
Jeff Bradberry
2c00d42ced Only use a default password if an import user doesn't already exist 2020-06-09 13:54:04 -04:00
Jeff Bradberry
d191edcaf1 Fix a Python 2 syntax error
it doesn't like multiple **kwargs, apparently.
2020-06-09 13:54:04 -04:00
Jeff Bradberry
65e16dc7ae Get and assign the related objects 2020-06-09 13:54:04 -04:00
Jeff Bradberry
95b22bf05b Begin to deal with existing matching assets
by using a registry allowing the lookup of Page objects by (frozen)
natural keys.
2020-06-09 13:54:04 -04:00
Jeff Bradberry
21e36ad19a Add the calculated natural key to the export data for each asset 2020-06-09 13:54:04 -04:00
Jeff Bradberry
f53920d3bf Begin changing Import to work with the structure created by Export 2020-06-09 13:54:04 -04:00
Jeff Bradberry
372570ce8e Extract out get_natural_key as a standalone function 2020-06-09 13:54:04 -04:00
Jeff Bradberry
6f28361bf5 Make serialize_asset use Pages to a greater extent 2020-06-09 13:54:04 -04:00
Jeff Bradberry
0877e5305c Modify get_natural_key to work on Pages 2020-06-09 13:54:04 -04:00
Jeff Bradberry
e4383c505f Make more use of the functionality of Page in get_assets
and related methods.  Also, rename get_resource_options -> get_options
and enhance_asset -> serialize_asset.
2020-06-09 13:54:04 -04:00
Jeff Bradberry
fb066eb52e Fold the other methods doing API calls into get_assets() 2020-06-09 13:54:04 -04:00
Jeff Bradberry
6162ff0439 Start to record the role membership
but not really, since it still isn't fully capturing the role content_object
2020-06-09 13:54:04 -04:00
Jeff Bradberry
dfe34563aa Resolve the natural keys of assets we've already collected 2020-06-09 13:54:04 -04:00
Jeff Bradberry
37cbf7691b Split out separate methods for the OPTIONS call and massaging each asset dict 2020-06-09 13:54:04 -04:00
Jeff Bradberry
9280198b0f Use a list of exportable resources to build up the parser
Also, handle an implicit export of everything.
2020-06-09 13:54:04 -04:00
Jeff Bradberry
2127f3c96d Add organizations as a resource type to export 2020-06-09 13:54:04 -04:00
Jeff Bradberry
9f7fecf8da Add basic import command 2020-06-09 13:54:04 -04:00
Jeff Bradberry
c1a07ff00b Limit export output to only those fields needed to create the resource 2020-06-09 13:54:04 -04:00
Jeff Bradberry
f21d6b1fc4 Actually query the API for the user or users requested 2020-06-09 13:54:04 -04:00
Jeff Bradberry
4312395a3a Normalize the requested resource into a pk
using the pk_or_name helper function.  Also, authenticate to the API.
2020-06-09 13:54:04 -04:00
Jeff Bradberry
c1f6fec532 Add skeleton of a custom 'export' resource
This only takes a flag for users at the moment, and does nothing in
particular with it.
2020-06-09 13:54:04 -04:00
Francois Herbert
d0384799fd
Add ability to monitor jobs and workflow_jobs via awx cli, fixes #6165
Signed-off-by: Francois Herbert <francois@herbert.org.nz>

Fixup linting

Remove timeout option, not really required and it's making the api test fail
2020-04-27 15:09:16 -04:00
AlanCoding
b90a296d41
Document and align the env var for OAuth token 2020-04-07 10:00:02 -04:00
Ryan Petrello
32627ce51a
promote AWX CLI installation instructions to the global INSTALL.md
a few users have had trouble finding these instructions, so let's move
them into the top level installation docs
2020-03-30 11:46:10 -04:00
Ryan Petrello
ea54815e6b
fix a bug that broke awx config
see: https://github.com/ansible/tower/issues/4206
2020-03-27 17:07:48 -04:00
Jeff Bradberry
91135f638f Add a connection kwarg to Page.from_json
if you don't reuse the connection when doing this, you lose your
authentication.
2020-03-24 15:27:51 -04:00
Ryan Petrello
06b3e54fb1
remove python2 support from awxkit 2020-03-19 09:02:39 -04:00
Ryan Petrello
3e0e4b6c8f
cli: add the ability to specify a token description w/ awx login
see: https://github.com/ansible/awx/issues/6122
2020-02-28 11:12:26 -05:00
Ryan Petrello
946d643795
cli: make launch with --monitor return code respect the final job status
see: https://github.com/ansible/awx/issues/5920
see: https://github.com/ansible/awx/issues/6079
2020-02-26 12:27:06 -05:00
Ryan Petrello
1800b49822
fix a py2/py3 compat bug in the settings CLI 2020-02-03 11:37:39 -05:00
Hideki Saito
437d9843d1 Fix to handle Str and JSON mix-in data correctly with settings API
- Fixed issue #5528

Signed-off-by: Hideki Saito <saito@fgrep.org>
2020-01-28 11:51:35 -05:00