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

Use ansible ping #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Use ansible ping #48

wants to merge 2 commits into from

Conversation

mscherer
Copy link
Contributor

@mscherer mscherer commented Mar 9, 2017

This PR implement a cleaner system for adding the ssh key for TOFU. By using ansible ping, we directly benefit from the parsing of all configuration file done by ansible, which will permit later to refactor and remove the code (once this one have been exercised enough)

Copy link
Contributor

@duck-rh duck-rh left a comment

Choose a reason for hiding this comment

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

btw, is the Ansible library still not considered public API (or part of it)? So we could use it to avoid parsing role meta ourselves for exemple.

else:
syslog.syslog("Running {}".format(c))
subprocess.call(c.split(), cwd=args.path)
env = os.environ.copy()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we do something like: env = os.environ.copy().update(c.get('env', {}))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it would work. I was also trying to avoid a line too long, but I forgot about update()

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree about oversized lines, but it took me a minute to wonder what you where trying to achieve with this loop, seemed too simple to be true :-)

@mscherer
Copy link
Contributor Author

That's still not a public API, so that's why I try to reduce our dependence on it. (since now, we would no longer need to parse the host file to get ssh_args, I will remove that code later)

@duck-rh
Copy link
Contributor

duck-rh commented Mar 15, 2017

ok, so you can merge once update() is in use :-)

@duck-rh
Copy link
Contributor

duck-rh commented Nov 9, 2017

Quack, still the update() thing would be nice. It's almost ready :-)

@duck-rh
Copy link
Contributor

duck-rh commented Dec 25, 2018

@mscherer it was nearly finished, any problem?

@mscherer mscherer force-pushed the use_ansible_ping branch 2 times, most recently from 01a38ca to f3c0d9e Compare July 1, 2020 13:36
@@ -230,30 +230,35 @@ def get_hostname(x):
# sure there is no funky chars for shell, and no space
if re.search('^[\\w.-]+$', hostname):
# avoid using the ssh stuff on salt bus host
Copy link
Contributor

Choose a reason for hiding this comment

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

is this comment thus not obsolete?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I will clean later again, as I think there is a few old stuff. I just did that during a meeting :)

else:
syslog.syslog("Running {}".format(c))
subprocess.call(shlex.split(c), cwd=args.path)
env = os.environ.copy()
for k, v in c.get('env', {}).iteritems():
Copy link
Contributor

Choose a reason for hiding this comment

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

I think update would be more efficient but well...

env = os.environ.copy()
for k, v in c.get('env', {}).iteritems():
env[k] = v
subprocess.call(shlex.split(c['cmd']),
Copy link
Contributor

Choose a reason for hiding this comment

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

While you're at it, It would be even safer to pass an array instead of constructing the command in a string by yourself.

@mscherer mscherer force-pushed the use_ansible_ping branch 4 times, most recently from a59e5a3 to fa8a2e1 Compare July 1, 2020 16:52
mscherer added 2 commits July 1, 2020 19:59
The main use is to be able to replace the ssh key adding
code with something based on ansible, since this will permit
to delegate inventory parsing to ansible
@mscherer mscherer force-pushed the use_ansible_ping branch from fa8a2e1 to f1d1df1 Compare July 1, 2020 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants