Skip to content

Commit 792f3f2

Browse files
feat: Ansible can read ansible.cfg and ssh keys from host
1 parent 8e4b1be commit 792f3f2

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

apps/ansible/init.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
cp -r /dockerized/host/home/.ssh /root/.ssh
6+
chmod -R go-rwx /root/.ssh
7+
8+
"$@"

docker-compose.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ services:
1111
ALPINE_PACKAGES: "tree"
1212
ansible: &ansible
1313
image: "willhallonline/ansible:${ANSIBLE_VERSION}-${ANSIBLE_BASE}"
14-
entrypoint: [ "ansible" ]
14+
entrypoint: [ "/init.sh", "ansible" ]
15+
volumes:
16+
- "${HOME}/.ssh:/dockerized/host/home/.ssh"
17+
- ./apps/ansible/init.sh:/init.sh
18+
environment:
19+
- ANSIBLE_CONFIG=ansible.cfg
1520
ansible-playbook:
1621
<<: *ansible
17-
entrypoint: [ "ansible-playbook" ]
22+
entrypoint: [ "/init.sh", "ansible-playbook" ]
1823
ab:
1924
<<: *alpine
2025
image: "ab"

0 commit comments

Comments
 (0)