Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import export #6125

Merged
merged 73 commits into from
Jun 19, 2020
Merged

Import export #6125

merged 73 commits into from
Jun 19, 2020

Conversation

jbradberry
Copy link
Contributor

@jbradberry jbradberry commented Feb 28, 2020

SUMMARY

Implement import and export commands in the new AWX CLI tool.

related #5146

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME
  • CLI
AWX VERSION
awx: 13.0.0

@jbradberry jbradberry self-assigned this Feb 28, 2020
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@jbradberry jbradberry mentioned this pull request Mar 23, 2020
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

even if it isn't an object being directly imported.  We might need it
for relations of things that are being imported.
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

since certain role grants will not be accepted by the api unless the user or team is part of the correct organization.
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@shanemcd
Copy link
Member

Can we add something under docs/ for this? Maybe an import_export.md?

@jbradberry
Copy link
Contributor Author

Can we add something under docs/ for this? Maybe an import_export.md?

@shanemcd How about this? https://github.com/ansible/awx/blob/393369adec482f73e963b73832e7e3ff8b689542/awxkit/awxkit/cli/docs/source/examples.rst#importexport

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@ghjm
Copy link
Contributor

ghjm commented Jun 18, 2020

FWIW, I ran this and it worked fine for all the things I tried.

@elyezer
Copy link
Member

elyezer commented Jun 18, 2020

I can't get the import to match the proper credentials owners, this is why the way that the import links a credential to users/organizations/teams is via the roles. The problem with that is that one can pass an owner to when creating a credential via the api (

awx/awx/api/serializers.py

Lines 2619 to 2633 in 1321d29

user = serializers.PrimaryKeyRelatedField(
queryset=User.objects.all(),
required=False, default=None, write_only=True, allow_null=True,
help_text=_('Write-only field used to add user to owner role. If provided, '
'do not give either team or organization. Only valid for creation.'))
team = serializers.PrimaryKeyRelatedField(
queryset=Team.objects.all(),
required=False, default=None, write_only=True, allow_null=True,
help_text=_('Write-only field used to add team to owner role. If provided, '
'do not give either user or organization. Only valid for creation.'))
organization = serializers.PrimaryKeyRelatedField(
queryset=Organization.objects.all(),
required=False, default=None, allow_null=True,
help_text=_('Inherit permissions from organization roles. If provided on creation, '
'do not give either user or team.'))
). If a team is passed, it will set some permissions to the credential (

awx/awx/api/serializers.py

Lines 2666 to 2667 in 1321d29

credential.admin_role.parents.add(team.admin_role)
credential.use_role.parents.add(team.member_role)
) but going to the team's roles it only has the use for that given credential but checking the credentials owners the following can be seen:

        "owners": [
            {
                "id": 3,
                "type": "organization",
                "name": "Ansible, Inc",
                "description": "Ansible is the simplest way to automate IT.",
                "url": "/api/v2/organizations/3/"
            },
            {
                "id": 3,
                "type": "team",
                "name": "Ansible Users",
                "description": "",
                "url": "/api/v2/teams/3/"
            }
        ]

But exporting the data and importing it does not bring the imported credential to the same state. I still not sure why but the imported data is not the same as the one found previously. This is how it is after the import:

        "owners": [
            {
                "id": 2,
                "type": "organization",
                "name": "Ansible, Inc",
                "description": "Ansible is the simplest way to automate IT.",
                "url": "/api/v2/organizations/2/"
            }
        ]

We may have some other cases and I still trying to sort all of those out.

@jbradberry
Copy link
Contributor Author

regate

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit a0413b7 into ansible:devel Jun 19, 2020
@jbradberry jbradberry deleted the import-export branch June 12, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants