Update image and README
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
52c347c342
commit
051c88729b
2 changed files with 72 additions and 33 deletions
44
README.md
44
README.md
|
|
@ -2,14 +2,46 @@
|
|||
|
||||
# ansible-docker
|
||||
|
||||
ansible in a container
|
||||
## Description
|
||||
|
||||
It include hashicorp vault and kubectl binary
|
||||
This project run ansible from a docker image.
|
||||
|
||||
You can use it with something like that :
|
||||
You need docker install on your desktop.
|
||||
|
||||
It include kubectl and helm binary
|
||||
|
||||
## Configure your environnement on Linux
|
||||
|
||||
You can use it with something like that in your ~/.bash_profile or ~/.bashrc :
|
||||
|
||||
```bash
|
||||
alias ansible-playbook='docker run --rm --dns=192.168.18.11 -ti -v $(pwd):/ansible/playbooks -v ~/.kube:/root/.kube -e VAULT_ADDR=$VAULT_ADDR -e VAULT_TOKEN="$(cat ~/.vault-token)" registry.example.net/ansible-docker:latest ansible-playbook'
|
||||
|
||||
ansible-playbook main.yml
|
||||
ansible-docker() {
|
||||
docker run --rm -ti -u $(id -u):$(id -g) --hostname $(hostname -s) \
|
||||
-v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -v /etc/shadow:/etc/shadow:ro \
|
||||
-v $(pwd):/ansible/playbooks -v ~/.kube:/home/$USER/.kube -v ~/.ansible:/home/$USER/.ansible \
|
||||
-e SSH_AUTH_SOCK="$SSH_AUTH_SOCK" -v $SSH_AUTH_SOCK:$SSH_AUTH_SOCK -v ~/.ssh:/home/$USER/.ssh \
|
||||
-v ~/.config:/home/$USER/.config -v ~/.cache:/home/$USER/.cache \
|
||||
quay.io/adrilinux/ansible:latest "$@"
|
||||
}
|
||||
alias ansible="ansible-docker ansible"
|
||||
alias ansible-config="ansible-docker ansible-config"
|
||||
alias ansible-connection="ansible-docker ansible-connection"
|
||||
alias ansible-console="ansible-docker ansible-console"
|
||||
alias ansible-doc="ansible-docker ansible-doc"
|
||||
alias ansible-galaxy="ansible-docker ansible-galaxy"
|
||||
alias ansible-inventory="ansible-docker ansible-inventory"
|
||||
alias ansible-playbook="ansible-docker ansible-playbook"
|
||||
alias ansible-pull="ansible-docker ansible-pull"
|
||||
alias ansible-test="ansible-docker ansible-test"
|
||||
alias ansible-vault="ansible-docker ansible-vault"
|
||||
```
|
||||
|
||||
Then you can run playbook like this:
|
||||
|
||||
```bash
|
||||
ansible-playbook -i inventories/local/ playbook.yml -l my_server --diff --check
|
||||
```
|
||||
|
||||
## Configure your environnement on Windows
|
||||
|
||||
Not tested actually, but help are welcome.
|
||||
|
|
|
|||
|
|
@ -1,34 +1,8 @@
|
|||
# docker build -f ansible.Dockerfile -t adrien/ansible ./
|
||||
|
||||
FROM python:3.12-alpine
|
||||
FROM python:3.8-alpine
|
||||
LABEL name="ansible" \
|
||||
version="latest"
|
||||
#RUN VAULT_VERSION=1.5.3 && KUBECTL_VERSION=v1.19.2 && HELM_VERSION=v3.3.3 && \
|
||||
RUN apk --update add --virtual build-dependencies gcc musl-dev libffi-dev openssl-dev build-base libvirt-dev && \
|
||||
pip3 install ansible asn1crypto bcrypt cachetools certifi cffi chardet cryptography dictdiffer \
|
||||
docker-py google-auth httplib2 hvac idna ipaddress Jinja2 jmespath jsonpatch jsonpointer jsonschema \
|
||||
kubernetes libvirt-python MarkupSafe oauthlib openshift paramiko pyasn1 pyasn1-modules pycparser \
|
||||
PyNaCl python-dateutil python-string-utils PyYAML q requests requests-oauthlib rsa ruamel.yaml \
|
||||
six simplejson urllib3 websocket-client ansible-lint openstacksdk cs && \
|
||||
apk add ca-certificates && \
|
||||
apk del build-dependencies && \
|
||||
rm -rf /var/cache/apk/* && \
|
||||
# wget https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip && \
|
||||
# unzip vault_${VAULT_VERSION}_linux_amd64.zip && \
|
||||
# install vault /usr/local/bin/vault -o root -g root -m 0755 && \
|
||||
# rm -f vault vault_${VAULT_VERSION}_linux_amd64.zip && \
|
||||
# wget https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl && \
|
||||
# install kubectl /usr/local/bin/kubectl -o root -g root -m 0755 && \
|
||||
# rm -f kubectl && \
|
||||
# wget https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz && \
|
||||
# tar -zxf helm-${HELM_VERSION}-linux-amd64.tar.gz && \
|
||||
# install -o root -g root -m 0755 linux-amd64/helm /usr/local/bin/helm && \
|
||||
# rm -fr helm-${HELM_VERSION}-linux-amd64.tar.gz linux-amd64 && \
|
||||
mkdir -p /etc/ansible /ansible && \
|
||||
echo "[local]" >> /etc/ansible/hosts && \
|
||||
echo "localhost" >> /etc/ansible/hosts && \
|
||||
ln -s /usr/local/bin/python3 /usr/bin/python3
|
||||
#RUN update-ca-certificates
|
||||
|
||||
ENV ANSIBLE_GATHERING=smart \
|
||||
ANSIBLE_HOST_KEY_CHECKING=false \
|
||||
|
|
@ -41,4 +15,37 @@ ENV ANSIBLE_GATHERING=smart \
|
|||
|
||||
WORKDIR /ansible/playbooks
|
||||
|
||||
RUN apk --no-cache --update add ca-certificates bash curl openssh-client openssl gettext libpq git && \
|
||||
# apk --no-cache upgrade && \
|
||||
ln -s /usr/local/bin/python3 /usr/bin/python3
|
||||
|
||||
#RUN VAULT_VERSION=1.7.3 && \
|
||||
# wget https://releases.hashicorp.com/vault/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_amd64.zip && \
|
||||
# unzip vault_${VAULT_VERSION}_linux_amd64.zip && \
|
||||
# install vault /usr/local/bin/vault -o root -g root -m 0755 && \
|
||||
# rm -f vault vault_${VAULT_VERSION}_linux_amd64.zip && \
|
||||
RUN KUBECTL_VERSION=v1.21.3 && HELM_VERSION=v3.6.2 && \
|
||||
wget https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl && \
|
||||
install kubectl /usr/local/bin/kubectl -o root -g root -m 0755 && \
|
||||
rm -f kubectl && \
|
||||
wget https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz && \
|
||||
tar -zxf helm-${HELM_VERSION}-linux-amd64.tar.gz && \
|
||||
install -o root -g root -m 0755 linux-amd64/helm /usr/local/bin/helm && \
|
||||
rm -fr helm-${HELM_VERSION}-linux-amd64.tar.gz linux-amd64 && \
|
||||
helm plugin install https://github.com/databus23/helm-diff
|
||||
|
||||
RUN apk --update add --virtual build-dependencies gcc rust cargo musl-dev libffi-dev openssl-dev build-base libvirt-dev postgresql-dev && \
|
||||
pip3 install ansible asn1crypto bcrypt cachetools certifi cffi chardet cryptography dictdiffer \
|
||||
docker-py google-auth httplib2 hvac idna ipaddress Jinja2 jmespath jsonpatch jsonpointer jsonschema \
|
||||
kubernetes libvirt-python MarkupSafe oauthlib openshift paramiko pyasn1 pyasn1-modules pycparser \
|
||||
PyNaCl python-dateutil python-string-utils PyYAML q requests requests-oauthlib rsa ruamel.yaml \
|
||||
six simplejson urllib3 websocket-client ansible-lint ovh openstacksdk cs && \
|
||||
# python-swiftclient boto boto3 psycopg2 ansible-modules-hashivault && \
|
||||
apk del build-dependencies && \
|
||||
rm -rf /var/cache/apk/* && \
|
||||
mkdir -p /etc/ansible /ansible && \
|
||||
echo "[local]" >> /etc/ansible/hosts && \
|
||||
echo "localhost" >> /etc/ansible/hosts
|
||||
#RUN update-ca-certificates
|
||||
|
||||
CMD ["ansible"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue