-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: master
Are you sure you want to change the base?
Use ansible ping #48
Conversation
5a1ea3d
to
6e09514
Compare
There was a problem hiding this 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() |
There was a problem hiding this comment.
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', {}))
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
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 :-)
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) |
ok, so you can merge once update() is in use :-) |
6e09514
to
166dd41
Compare
Quack, still the update() thing would be nice. It's almost ready :-) |
@mscherer it was nearly finished, any problem? |
01a38ca
to
f3c0d9e
Compare
files/generate_ansible_command.py
Outdated
@@ -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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 :)
files/generate_ansible_command.py
Outdated
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(): |
There was a problem hiding this comment.
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...
files/generate_ansible_command.py
Outdated
env = os.environ.copy() | ||
for k, v in c.get('env', {}).iteritems(): | ||
env[k] = v | ||
subprocess.call(shlex.split(c['cmd']), |
There was a problem hiding this comment.
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.
a59e5a3
to
fa8a2e1
Compare
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
fa8a2e1
to
f1d1df1
Compare
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)