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

making the cli use AWXKIT_CREDENTIAL_FILE #9491

Merged
merged 1 commit into from
Oct 13, 2021

Conversation

sezanzeb
Copy link
Contributor

@sezanzeb sezanzeb commented Mar 5, 2021

SUMMARY
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
  • CLI
AWX VERSION
awx: 17.0.1
ADDITIONAL INFORMATION

setup:

> nano /awx_credentials.json
> export AWXKIT_CREDENTIAL_FILE=/awx_credentials.json
> cat /awx_credentials.json 
{
  "default": {
    "username": "testuser",
    "password": "testpassword"
  }
}

before:

> awx login
...
Error retrieving an OAuth2.0 token (<class 'awxkit.exceptions.Unauthorized'>).

after:

> awx login
{
     "token": "***"
}

@sezanzeb sezanzeb marked this pull request as draft March 5, 2021 11:24
@sezanzeb sezanzeb changed the title Awxkit credential file making the cli use AWXKIT_CREDENTIAL_FILE Mar 5, 2021
@awxbot awxbot added the type:bug label Mar 5, 2021
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@sezanzeb sezanzeb marked this pull request as ready for review March 5, 2021 12:20
@jakemcdermott
Copy link
Contributor

jakemcdermott commented Mar 5, 2021

@unlikelyzero @tiagodread This addresses a bug with the awxkit config precedence. (CLI args would now override config file vars).

That's probably (?) the expected behavior but it's possible that some test suites and other tooling might implicitly rely on the unexpected (current) behavior. Can you give this a run to make sure it all still works?

@sezanzeb
Copy link
Contributor Author

sezanzeb commented Mar 5, 2021

tooling might implicitly rely on the unexpected (current) behavior

at least for awx login the default cli values "admin" and "password" overwrote anything stored in there, so no tooling would have been able to use the configuration file at the moment via that command as far as I can tell.

@sezanzeb
Copy link
Contributor Author

sezanzeb commented Apr 7, 2021

Any updates?

@jakemcdermott

as already mentioned, AWXKIT_CREDENTIAL_FILE did not have any effect prior to this PR, it was completely ignored. The precedence is not the issue here.

@shanemcd
Copy link
Member

Hello. If you could please rebase this and resolve the conflicts, we'll get this merged.

@sezanzeb
Copy link
Contributor Author

Thanks for getting back to this. Should be good to go now, the changes still seem to work

@sezanzeb
Copy link
Contributor Author

@shanemcd

@sezanzeb
Copy link
Contributor Author

sezanzeb commented Sep 9, 2021

tower-cli used to support config files. This merge request has unittests so that it doesn't break again, yet it has been open for 4 months now. I even merged the conflicts in on the same day of your request. To be honest, this is somewhat discouraging me to help the project out in the future... I'm not trying to be rude, but maintaining our AWX setup has caused us/me a lot of work, which adds to the frustration a bit. sorry

@sezanzeb
Copy link
Contributor Author

sezanzeb commented Sep 9, 2021

Take care to make sure no merge commits are in the submission, and use git rebase vs. git merge for this reason. (readme)

Whoops, sorry for that. I'll just squash all commits later, should be a fresh single-commit merge request afterwards

@sezanzeb
Copy link
Contributor Author

sezanzeb commented Sep 12, 2021

here you are, the PR is now a single commit (also with --signoff)

metavar='TEXT',
)
auth.add_argument(
'--conf.password',
default=env.get('CONTROLLER_PASSWORD', env.get('TOWER_PASSWORD', 'password')),
default=env.get('CONTROLLER_PASSWORD', env.get('TOWER_PASSWORD', config_password)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default won't show in the help text, will it?

(sorry for the surface-level question, I'm just starting to go over this)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, not as long argparse.ArgumentDefaultsHelpFormatter is not used

image

Copy link
Member

@shanemcd shanemcd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@shanemcd shanemcd merged commit 517f1d7 into ansible:devel Oct 13, 2021
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.

None yet

5 participants