ansible / tower-cli

THIS TOOL IS NO LONGER UNDER ACTIVE DEVELOPMENT. This tool is being phased out in favor of the new official AWX CLI
https://github.com/ansible/awx/tree/devel/awxkit/awxkit/cli/docs
Apache License 2.0
361 stars 151 forks source link

Import of users doesn't work #581

Open jomeier opened 6 years ago

jomeier commented 6 years ago

Hi,

today I tried out the export / import feature of tower-cli.

I installed the latest awx version on my machine. I started it and waited until it was accessible through the web ui. I logged in.

On the command line I exported all settings like this:

tower-cli receive --all > test.json

test.json was filled with data.

Afterwards I imported this data again to the same instance of AWX like this:

tower-cli send test.json

I get this error message:

Asset of type user is missing identifier field username
Error: One or more errors encountered in provided assets, stopping import

I appended the test.json file.

Best regards,

Josef

test.txt

Versions: Tower CLI 3.3.0 API v2 AWX 1.0.6.41 Ansible 2.6.1

jomeier commented 6 years ago

I found out that there where lines like this in the test.json file:

...
{
  "asset_type": "user"
}
...

If I add the two properties "username" and "email" to something like this:

...
  {
    "username": "admin",
    "email": "dudu@duduhome.com",
    "asset_type": "user"
  }
...

the import works.

Is this the expected behaviour ?

jomeier commented 6 years ago

Why are the user names not exported?

Lot's of objects are connected to a certain user. If they are not known to tower, the import will not work at all.

john-westcott-iv commented 6 years ago

@jomeier, This is strange behavior. In the version information you listed, is that the server you are exporting out of, importing into, or both? The user is correctly exported for me (see below) so I want to check using the same versions as you. Also, can you try to download and build tower-cli from source to see if you are still getting the same issue.

tower-cli receive --user admin --tower-host http://localhost:8081
[
  {
    "username": "admin", 
    "first_name": "", 
    "last_name": "", 
    "email": "admin@example.com", 
    "is_superuser": true, 
    "asset_type": "user"
  }
]
jomeier commented 6 years ago

@john-westcott-iv Yes you are right: I exported the user data from the same AWX version I tried to import it afterwards. I expected to get it working.

I also tried out to clear all AWX data with

tower-cli empty --all

before reimporting the formerly exported data. Same results.

After building tower-cli from source with

sudo make install

I get the same weird behaviour as described in my initial issue.

jomeier commented 6 years ago

A fresh installation of AWX V1.0.7.2 shows the same behaviour.

tower-cli receive --user admin
[
  {
    "asset_type": "user"
  }
]
decentral1se commented 6 years ago

Also seeing this on a fresh pip install ansible-tower-cli and latest docker awx setup.

jomeier commented 6 years ago

This is my PR which exports more user attributes. Makes the import work again.

https://github.com/ansible/tower-cli/pull/586

srgvg commented 6 years ago

Seems like a bug in AWX API, which I myself noticed in 1.0.7.2 and that seems fixed in 2.0.1?

see for more details: https://github.com/ansible/tower-cli/pull/586#issuecomment-432176155

tumluliu commented 4 years ago

For my data migration from awx 2.0.1 to 9.1.0 with tower-cli 3.3.7, this issue still exists

TwoTwenty commented 4 years ago

For my data migration from awx 2.0.1 to 9.1.0 with tower-cli 3.3.7, this issue still exists

I am in the same boat still to with similar versions. AWX 2.1.2.0 tower-cli 3.3.8