.
Some checks failed
/ build-docker-image (push) Failing after 7s

This commit is contained in:
2024-09-04 22:48:43 +01:00
parent d5edc731f3
commit 488429244e
8 changed files with 64 additions and 1 deletions

View File

@@ -22,5 +22,6 @@ jobs:
uses: docker/build-push-action@v6
with:
context: ${{gitea.workspace}}/docker
file: ansible-playbook.Dockerfile
push: true
tags: git.limbosolutions.com/kb/ansible:latest
tags: git.limbosolutions.com/kb/ansible-playbook:dev

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
**/**env.local

2
docker/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
playbook-workspace/**
workspace/**

View File

@@ -6,3 +6,9 @@ RUN apt-get install -y openssh-client
RUN apt-get install python3-pip -y
RUN apt-get install python3-virtualenv -y
RUN pip3 install ansible --break-system-packages
RUN pip3 install ansible-runner --break-system-packages
RUN mkdir /workspace
RUN mkdir /scripts
COPY scripts /scripts
COPY playbook-sample-workspace /workspace
ENTRYPOINT ["python3", "/scripts/run-ansible-playbook.py"]

View File

@@ -0,0 +1,14 @@
#/bin/bash
source docker/docker-run-ansible-playbook-local.env.local
docker build docker \
-f docker/ansible-playbook.Dockerfile \
-t ${IMAGE_NAME}
docker run --rm \
-e ANSIBLE_PLAYBOOK_INVENTORY=$ANSIBLE_PLAYBOOK_INVENTORY \
-v ${VOLUME_PATH}:/workspace \
$IMAGE_NAME

View File

@@ -0,0 +1,9 @@
- name: Hello from ansible
hosts: all
tasks:
- name: Ping my hosts
ansible.builtin.ping:
- name: Print message
ansible.builtin.debug:
msg: Hello world

View File

@@ -0,0 +1,29 @@
import os
import sys
from ansible_runner import Runner, RunnerConfig
def executePlaybook():
rc = RunnerConfig(
private_data_dir="/workspace"
)
rc.playbook=os.environ.get('ANSIBLE_PLAYBOOK', "site.yml")
rc.inventory=os.environ.get('ANSIBLE_PLAYBOOK_INVENTORY', "127.0.0.1,")
if(rc.inventory=="127.0.0.1,"):
rc.cmdline_args= "--limit 127.0.0.1 --connection local"
rc.prepare()
r = Runner(config=rc)
r.run()
def main():
executePlaybook()
main()

View File

@@ -0,0 +1 @@
echo ola mundo