Commit 7cc3a44f authored by Jürgen Haas's avatar Jürgen Haas

ansible-inventories/arocom#2898 Add script to run ansible inside Docker...

ansible-inventories/arocom#2898 Add script to run ansible inside Docker container from console or cronjob
parent 4333b09c
......@@ -36,4 +36,12 @@
groups: docker
append: yes
- name: Deply ansible script to run inside Docker
template:
src: ansible.sh
dest: /usr/local/bin/ansible
owner: root
group: root
mode: 0755
when: not excluded_roles or "gitlab-runner" not in excluded_roles
#!/bin/bash
COMPANY={{ lookup('env','ANSIBLE_COMPANY') }}
DOCKERIFACE=$(/sbin/ifconfig docker0 2>/dev/null | grep 'inet addr:' | cut -d: -f2 | cut -d' ' -f1)
if [ "x${DOCKERIFACE}" != "x" ]; then
FLUENTD="--env FLUENTD_SERVER=${DOCKERIFACE}"
fi
docker run \
--env ANSIBLE_LOG_PATH=/var/log/ansible/$COMPANY.log \
--env FLUENTD_COMPANY=$COMPANY \
${FLUENTD} \
--env-file /home/gitlab-runner/.a/environment \
--volume /home/gitlab-runner/.ssh/id_rsa:/root/.ssh/id_rsa \
--volume /home/gitlab-runner/.a/variables.yml:/root/.ansible/secrets \
--volume /home/gitlab-runner/.a/inventories/$COMPANY:/root/.ansible \
--volume /var/log/ansible:/var/log/ansible \
registry.lakedrops.com/ansible-inventories/$COMPANY \
$@
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment