diff --git a/docker/devel/Dockerfile b/docker/devel/Dockerfile index 774d8ac..d6506d1 100644 --- a/docker/devel/Dockerfile +++ b/docker/devel/Dockerfile @@ -6,91 +6,14 @@ COPY execute.sh /execute.sh COPY playbook.yml /playbook.yml RUN set -x && \ - apk add --no-cache python3 py3-pip openssl-dev python3-dev libffi-dev ca-certificates gcc make musl-dev git yaml-dev && \ - apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community rust cargo && \ + apk add --no-cache python3 py3-pip openssl-dev python3-dev libffi-dev ca-certificates gcc make musl-dev git yaml-dev rust cargo && \ pip3 install -U pip && \ - pip3 install https://github.com/ansible/ansible/archive/devel.tar.gz jmespath netaddr && \ - apk del openssl-dev python3-dev libffi-dev gcc make musl musl-dev git yaml pkgconf rust cargo - -RUN set -x && \ - ansible-galaxy collection install --pre \ - amazon.aws \ - ansible.netcommon \ - ansible.posix \ - ansible.windows \ - arista.eos \ - awx.awx \ - azure.azcollection \ - check_point.mgmt \ - chocolatey.chocolatey \ - cisco.aci \ - cisco.asa \ - cisco.intersight \ - cisco.ios \ - cisco.iosxr \ - cisco.meraki \ - cisco.mso \ - cisco.nso \ - cisco.nxos \ - cisco.ucs \ - cloudscale_ch.cloud \ - community.aws \ - community.azure \ - community.crypto \ - community.digitalocean \ - community.docker \ - community.general \ - community.grafana \ - community.hrobot \ - community.kubernetes \ - community.libvirt \ - community.mongodb \ - community.mysql \ - community.network \ - community.okd \ - community.postgresql \ - community.proxysql \ - community.rabbitmq \ - community.routeros \ - community.skydive \ - community.vmware \ - community.windows \ - community.zabbix \ - containers.podman \ - cyberark.conjur \ - cyberark.pas \ - dellemc.os10 \ - dellemc.os6 \ - dellemc.os9 \ - f5networks.f5_modules \ - fortinet.fortimanager \ - fortinet.fortios \ - frr.frr \ - gluster.gluster \ - google.cloud \ - hetzner.hcloud \ - ibm.qradar \ - infinidat.infinibox \ - junipernetworks.junos \ - mellanox.onyx \ - netapp.aws \ - netapp.elementsw \ - netapp_eseries.santricity \ - netapp.ontap \ - netbox.netbox \ - ngine_io.cloudstack \ - ngine_io.exoscale \ - ngine_io.vultr \ - openstack.cloud \ - openvswitch.openvswitch \ - ovirt.ovirt \ - purestorage.flasharray \ - purestorage.flashblade \ - servicenow.servicenow \ - splunk.es \ - theforeman.foreman \ - vyos.vyos \ - wti.remote && \ - python3 /tmp/clean_collections.py + pip3 install jmespath netaddr && \ + pip3 install --no-compile ansible && \ + pip3 install -U https://github.com/ansible/ansible/archive/devel.tar.gz && \ + apk del py3-pip openssl-dev python3-dev libffi-dev ca-certificates gcc make musl-dev git yaml rust cargo && \ + python3 /tmp/clean_collections.py && \ + rm -rf /root/.cache && \ + rm -rf /root/.cargo CMD ["/bin/sh", "/execute.sh"] diff --git a/docker/devel/clean_collections.py b/docker/devel/clean_collections.py index 336fe7e..abc687e 100644 --- a/docker/devel/clean_collections.py +++ b/docker/devel/clean_collections.py @@ -2,8 +2,9 @@ import os import shutil +import ansible_collections -root = '/root/.ansible/collections/ansible_collections' +root = ansible_collections.__path__[0] for namespace in os.listdir(root): namespace = os.path.join(root, namespace) @@ -21,3 +22,7 @@ shutil.rmtree(path) else: os.unlink(path) + else: + modules = os.path.join(path, 'modules') + if os.path.isdir(modules): + shutil.rmtree(modules) diff --git a/docker/stable/Dockerfile b/docker/stable/Dockerfile index 43743ce..8884e14 100644 --- a/docker/stable/Dockerfile +++ b/docker/stable/Dockerfile @@ -1,14 +1,18 @@ FROM alpine MAINTAINER Matt Martz +COPY clean_collections.py /tmp/clean_collections.py +COPY execute.sh /execute.sh +COPY playbook.yml /playbook.yml + RUN set -x && \ - apk add --no-cache python3 py3-pip openssl-dev python3-dev libffi-dev ca-certificates gcc make musl-dev git yaml-dev && \ - apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community rust cargo && \ + apk add --no-cache python3 py3-pip openssl-dev python3-dev libffi-dev ca-certificates gcc make musl-dev git yaml-dev rust cargo && \ pip3 install -U pip && \ pip3 install ansible jmespath netaddr && \ - apk del openssl-dev python3-dev libffi-dev gcc make musl musl-dev git yaml pkgconf rust cargo + apk del py3-pip openssl-dev python3-dev libffi-dev ca-certificates gcc make musl-dev git yaml rust cargo && \ + python3 /tmp/clean_collections.py && \ + rm -rf /root/.cache && \ + rm -rf /root/.cargo -COPY execute.sh /execute.sh -COPY playbook.yml /playbook.yml CMD ["/bin/sh", "/execute.sh"] diff --git a/docker/stable/clean_collections.py b/docker/stable/clean_collections.py new file mode 100644 index 0000000..abc687e --- /dev/null +++ b/docker/stable/clean_collections.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +import os +import shutil +import ansible_collections + +root = ansible_collections.__path__[0] + +for namespace in os.listdir(root): + namespace = os.path.join(root, namespace) + if not os.path.isdir(namespace): + continue + for collection in os.listdir(namespace): + collection = os.path.join(namespace, collection) + if not os.path.isdir(collection): + continue + for path in os.listdir(collection): + path = os.path.join(collection, path) + basename = os.path.basename(path) + if basename != 'plugins': + if os.path.isdir(path): + shutil.rmtree(path) + else: + os.unlink(path) + else: + modules = os.path.join(path, 'modules') + if os.path.isdir(modules): + shutil.rmtree(modules)