UNCLASSIFIED

Skip to content
Snippets Groups Projects
Commit cd326cb0 authored by kmc-home's avatar kmc-home
Browse files

update ansible

parent e332ba24
No related merge requests found
......@@ -7,4 +7,6 @@ read -p "Press Enter to continue..."
docker compose up -d
read -p "Press Enter to continue..."
source /root/woac-infra-demo/uv-env/bin/activate
cd ansible
ansible -i inventory/hosts all -m ping
......@@ -3,7 +3,6 @@ red-web ansible_host=172.22.0.2
red-basic ansible_host=172.22.0.4
[blue]
blue-alma ansible_host=172.23.0.3
blue-basic ansible_host=172.23.0.2
[grey]
......
[red]
red-web
red-basic
[blue]
blue-alma
blue-basic
[grey]
grey-1
grey-2
[all:vars]
ansible_user=ansible
ansible_ssh_private_key_file=../docker/keys/ansible_key
......@@ -23,17 +23,6 @@ services:
expose:
- "22"
blue-alma:
build:
context: docker
dockerfile: blue/Dockerfile.alma
hostname: blue-alma
networks:
blue_network:
ipv4_address: 172.23.0.3
expose:
- "22"
blue-basic:
build:
context: docker
......
FROM almalinux:9
# Install essential packages
RUN dnf -y install openssh-server python3 sudo \
&& dnf clean all
# SSH configuration
RUN mkdir /run/sshd
RUN echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
RUN echo 'PubkeyAuthentication yes' >> /etc/ssh/sshd_config
# Create ansible user
RUN useradd -m -s /bin/bash ansible \
&& echo "ansible ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/ansible
# Create SSH directory structure
RUN mkdir -p /home/ansible/.ssh \
&& chown -R ansible:ansible /home/ansible/.ssh \
&& chmod 700 /home/ansible/.ssh
# Copy SSH key
COPY keys/ansible_key.pub /home/ansible/.ssh/authorized_keys
# Set proper permissions
RUN chown ansible:ansible /home/ansible/.ssh/authorized_keys \
&& chmod 600 /home/ansible/.ssh/authorized_keys
# Set blue team prompt
RUN echo 'PS1="\[\033[1;36m\][\u@\h \W]\\$ \[\033[0m\]"' >> /home/ansible/.bashrc
# Generate SSH host keys
RUN ssh-keygen -A
# Create required directory for sshd
RUN mkdir -p /var/run/sshd
# Start SSH daemon
ENTRYPOINT ["/usr/sbin/sshd", "-D", "-e"]
# FROM almalinux:9
# # Install essential packages
# RUN dnf -y install openssh-server python3 sudo \
# && dnf clean all
# # SSH configuration
# RUN mkdir /run/sshd
# RUN echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
# RUN echo 'PubkeyAuthentication yes' >> /etc/ssh/sshd_config
# # Create ansible user
# RUN useradd -m -s /bin/bash ansible \
# && echo "ansible ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/ansible
# # Copy SSH key
# COPY keys/ansible_key.pub /home/ansible/.ssh/authorized_keys
# # Set blue team prompt
# RUN echo 'PS1="\[\033[1;36m\][\u@\h \W]\\$ \[\033[0m\]"' >> /home/ansible/.bashrc
# # Set proper permissions
# RUN mkdir -p /home/ansible/.ssh \
# && chown -R ansible:ansible /home/ansible/.ssh \
# && chmod 700 /home/ansible/.ssh \
# && chmod 600 /home/ansible/.ssh/authorized_keys
# CMD ["/usr/sbin/sshd", "-D"]
# test-inventory.ini
my-ansible ansible_host=172.18.0.3 ansible_user=ansible ansible_ssh_private_key_file=docker/keys/ansible_key
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