FROM alpine:3.20

LABEL org.opencontainers.image.title="Ansible Test Executor"
LABEL org.opencontainers.image.description="Ansible integrations for infrastructure test automation"

RUN apk add --no-cache \
        ansible \
        bash \
        ca-certificates \
        curl \
        freetds \
        freetds-dev \
        gcc \
        git \
        krb5 \
        krb5-dev \
        libffi-dev \
        musl-dev \
        openssh-client \
        openssl-dev \
        py3-pip \
        python3 \
        python3-dev \
        sshpass \
    && pip3 install --no-cache-dir --break-system-packages \
        'cryptography>=41.0' \
        'fpdf2>=2.7' \
        'jmespath>=1.0' \
        'jsonschema>=4.23' \
        'ncclient>=0.6' \
        'netmiko>=4.0' \
        packaging \
        'paramiko>=2.7' \
        'pymssql>=2.2' \
        'pyvmomi>=8.0' \
        'pywinrm[kerberos]>=0.4' \
        'pyyaml>=6.0' \
        requests \
        requests-kerberos \
        requests-ntlm \
        scp \
        'xmltodict>=0.13' \
    && ansible-galaxy collection install \
        ansible.netcommon \
        ansible.utils \
        ansible.windows \
        cisco.asa \
        cisco.ios \
        cisco.nxos \
        community.crypto \
        community.general \
        community.vmware \
        microsoft.sql \
    && apk del --no-network \
        freetds-dev \
        gcc \
        krb5-dev \
        libffi-dev \
        musl-dev \
        openssl-dev \
        python3-dev \
    && apk add --no-cache util-linux \
    && mkdir -p /etc/ansible \
    && printf '%s\n' \
        '[defaults]' \
        'host_key_checking = False' \
        'stdout_callback = yaml' \
        'retry_files_enabled = False' \
        'inventory = /workspace/assets.yml' \
        '' \
        '[ssh_connection]' \
        'pipelining = True' \
        'control_path = /tmp/ansible-%%h-%%p-%%r' \
        > /etc/ansible/ansible.cfg

WORKDIR /workspace
CMD ["ansible-playbook", "--version"]
