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

Create a container executor #116

Open
apenella opened this issue Nov 19, 2022 · 2 comments
Open

Create a container executor #116

apenella opened this issue Nov 19, 2022 · 2 comments

Comments

@apenella
Copy link
Owner

What
Execute ansible command inside a container

@kolcak
Copy link

kolcak commented Sep 7, 2023

problem line:
https://github.com/apenella/go-ansible/blob/master/pkg/playbook/ansiblePlaybook.go#L135

workarround:

  1. create script file ./ansible-playbook.sh
#!/bin/sh

# @see https://hub.docker.com/r/alpine/ansible
exec docker run --rm -v $(pwd)/source:/source -w /source alpine/ansible ansible-playbook "$@"

test: ./ansible-playbook.sh --help

  1. change Binary file in your project
	playbook := &playbook.AnsiblePlaybookCmd{
		....
		Binary: "./ansible-playbook.sh",
		....
	}
  1. enjoy

I tried used alias but aliases are a shell construct. They aren't passed to sub processes. :(

@apenella
Copy link
Owner Author

apenella commented Sep 8, 2023

Hi @kolcak
Thank you very much for your workaround!
The idea I have is to provide a solution that does not require an intermediate script but I will do a further evaluation when I tackle that feature. Meanwhile, I keep your approach as a plan B.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants