Skip to content

Commit

Permalink
19: Add dynamic invetory, to be supplied by layer (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
DistroByte authored Dec 27, 2023
1 parent 564da66 commit cb383a4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ FROM debian:bookworm-slim AS base

WORKDIR /root

COPY build-files build-files
RUN cat build-files/.bashrc >> /root/.bashrc && cat build-files/ansible.cfg >> /root/ansible.cfg

RUN apt update && apt install --no-install-recommends -y gnupg \
dnsutils \
net-tools \
nmap \
openssh-client \
python3 \
python-is-python3 \
python3-pip \
Expand All @@ -19,4 +18,9 @@ RUN apt update && apt install --no-install-recommends -y gnupg \

RUN pipx install --include-deps ansible

COPY build-files/ build-files/
RUN cat build-files/.bashrc >> /root/.bashrc
RUN cat build-files/ansible.cfg >> /root/ansible.cfg
RUN rm -rf build-files

CMD ["/bin/bash"]
17 changes: 11 additions & 6 deletions build-files/ansible.cfg
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
[defaults]
roles_path = roles
inventory = inventory
interpreter_python = auto_silent
# Only gather on first time a host is seen
gathering = smart
gathering = smart ;Only gather on first time a host is seen
inventory = /root/inventory.yml
fact_caching = ansible.builtin.jsonfile
fact_caching_connection = /tmp/ansible_facts
cache_timeout = 3600

# ssh
timeout = 15
timeout = 15 ;ssh timeout

[inventory]
enable_plugins = host_list, script, yaml, ini, auto
cache = yes
cache_connection = /tmp/ansible_inventory

[ssh_connection]
pipelining = True
Expand Down
10 changes: 5 additions & 5 deletions containsible
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ run_containsible() {

if [ "$use_local_image" = true ]; then
echo "Skipping version check for local image."
docker run -it --hostname "$environment" ghcr.io/distrobyte/containsible:latest
docker run -it --hostname "$environment" ghcr.io/distrobyte/containsible-$environment:latest
else
docker run -it --hostname "$environment" ghcr.io/distrobyte/containsible:latest
docker run -it --hostname "$environment" ghcr.io/distrobyte/containsible-$environment:latest
fi
}

Expand All @@ -32,7 +32,7 @@ update_container() {
if $use_local_image; then
echo "Skipping update for local image."
else
docker pull ghcr.io/distrobyte/containsible:latest >/dev/null 2>&1
docker pull ghcr.io/distrobyte/containsible-$environment:latest >/dev/null 2>&1
echo "Container updated successfully."
fi
}
Expand Down Expand Up @@ -81,9 +81,9 @@ handle_run_subcommand() {
if [ "$use_local_image" = false ]; then
echo "Pulling the latest remote image..."
if [ "$verbose" = true ]; then
docker pull ghcr.io/distrobyte/containsible:latest
docker pull ghcr.io/distrobyte/containsible-$environment:latest
else
docker pull ghcr.io/distrobyte/containsible:latest >/dev/null 2>&1
docker pull ghcr.io/distrobyte/containsible-$environment:latest >/dev/null 2>&1
fi
echo "Latest remote image pulled successfully."
fi
Expand Down

0 comments on commit cb383a4

Please sign in to comment.