mirror of
https://github.com/status-im/ansible-role-mongodb.git
synced 2025-02-17 07:26:32 +00:00
Add docker container proxy for cache packages of yum, apt and pip repos.
This commit is contained in:
parent
d21c149fdf
commit
1fa78ca6da
@ -46,17 +46,17 @@ env:
|
||||
DOCKER_PRIVILEGED=true
|
||||
- >
|
||||
DISTRIBUTION=ubuntu-upstart
|
||||
DIST_VERSION=14.04
|
||||
DIST_VERSION=14_04-builded
|
||||
MONGODB_VERSION=4.0
|
||||
DOCKER_PRIVILEGED=true
|
||||
- >
|
||||
DISTRIBUTION=ubuntu-upstart
|
||||
DIST_VERSION=14.04
|
||||
DIST_VERSION=14_04-builded
|
||||
MONGODB_VERSION=3.6
|
||||
DOCKER_PRIVILEGED=true
|
||||
- >
|
||||
DISTRIBUTION=ubuntu-upstart
|
||||
DIST_VERSION=14.04
|
||||
DIST_VERSION=14_04-builded
|
||||
MONGODB_VERSION=3.4
|
||||
DOCKER_PRIVILEGED=true
|
||||
- >
|
||||
|
@ -3,7 +3,7 @@ FROM amazonlinux:2
|
||||
# This is needed so that ansible managed to read "ansible_default_ipv4"
|
||||
# This step is needed since standard CentOS docker image does not come with i
|
||||
# This package seems to be required for Mongo 3.2 and downwards
|
||||
RUN yum install iproute initscripts -y
|
||||
RUN yum install iproute initscripts python-pip python-devel -y
|
||||
|
||||
# we can has SSH
|
||||
EXPOSE 22
|
||||
|
@ -2,7 +2,7 @@ FROM centos:6
|
||||
|
||||
# This is needed so that ansible managed to read "ansible_default_ipv4"
|
||||
# This step is needed since standard CentOS docker image does not come with EPEL installed by default
|
||||
RUN yum install iproute epel-release -y
|
||||
RUN yum install iproute epel-release python-pip python-devel -y
|
||||
|
||||
# we can has SSH
|
||||
EXPOSE 22
|
||||
|
@ -2,7 +2,7 @@ FROM centos:7
|
||||
|
||||
# This is needed so that ansible managed to read "ansible_default_ipv4"
|
||||
# This step is needed since standard CentOS docker image does not come with EPEL installed by default
|
||||
RUN yum install iproute epel-release -y
|
||||
RUN yum install iproute epel-release python-pip python-devel -y
|
||||
|
||||
# we can has SSH
|
||||
EXPOSE 22
|
||||
|
@ -3,5 +3,5 @@ FROM debian:8
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt update && \
|
||||
apt install --yes python-minimal && \
|
||||
apt install --yes python-minimal python-pip && \
|
||||
rm /lib/systemd/system/getty@.service
|
||||
|
@ -3,7 +3,7 @@ FROM debian:9
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt update && \
|
||||
apt install --yes python-minimal systemd gnupg
|
||||
apt install --yes python-minimal systemd gnupg python-pip
|
||||
|
||||
RUN cd /lib/systemd/system/sysinit.target.wants/ && \
|
||||
ls | grep -v systemd-tmpfiles-setup.service | xargs rm -f && \
|
||||
|
7
tests/Dockerfile.ubuntu-upstart_14_04-builded
Normal file
7
tests/Dockerfile.ubuntu-upstart_14_04-builded
Normal file
@ -0,0 +1,7 @@
|
||||
FROM ubuntu-upstart
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install --yes python-minimal python-pip python-dev iproute2
|
||||
|
@ -3,19 +3,6 @@ FROM ubuntu:16.04
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt update && \
|
||||
apt install --yes python-pip curl jq && \
|
||||
pip install apt-select && \
|
||||
EXTERNAL_IP=`curl -s https://ipinfo.io/ip` && \
|
||||
echo "EXTERNAL_IP is ${EXTERNAL_IP}" && \
|
||||
DATA_IP=`curl -s https://json.geoiplookup.io/$EXTERNAL_IP` && \
|
||||
echo $DATA_IP && \
|
||||
COUNTRY_IP=`echo $DATA_IP | jq '.country_code' | tr -d '"'` && \
|
||||
apt-select -C $COUNTRY_IP -t 1 -m one-week-behind && \
|
||||
cat sources.list && \
|
||||
cp /etc/apt/sources.list /etc/apt/sources.list.backup && \
|
||||
mv -f sources.list /etc/apt/
|
||||
|
||||
RUN apt update && \
|
||||
apt install --yes python-minimal iproute2 && \
|
||||
rm -f /lib/systemd/system/getty@.service
|
||||
apt install --yes python-minimal python-pip python-dev iproute2 && \
|
||||
rm /lib/systemd/system/getty@.service
|
||||
|
||||
|
@ -3,20 +3,7 @@ FROM ubuntu:18.04
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt update && \
|
||||
apt install --yes python-pip curl jq && \
|
||||
pip install apt-select && \
|
||||
EXTERNAL_IP=`curl -s https://ipinfo.io/ip` && \
|
||||
echo "EXTERNAL_IP is ${EXTERNAL_IP}" && \
|
||||
DATA_IP=`curl -s https://json.geoiplookup.io/$EXTERNAL_IP` && \
|
||||
echo $DATA_IP && \
|
||||
COUNTRY_IP=`echo $DATA_IP | jq '.country_code' | tr -d '"'` && \
|
||||
apt-select -C $COUNTRY_IP -t 1 -m one-week-behind && \
|
||||
cat sources.list && \
|
||||
cp /etc/apt/sources.list /etc/apt/sources.list.backup && \
|
||||
mv -f sources.list /etc/apt/
|
||||
|
||||
RUN apt update && \
|
||||
apt install --yes python-minimal systemd gnupg iproute2
|
||||
apt install --yes python-minimal python-pip python-dev systemd gnupg iproute2
|
||||
|
||||
RUN cd /lib/systemd/system/sysinit.target.wants/ && \
|
||||
ls | grep -v systemd-tmpfiles-setup.service | xargs rm -f && \
|
||||
|
3
tests/files/etc/apt/apt.conf.d/proxy.conf
Normal file
3
tests/files/etc/apt/apt.conf.d/proxy.conf
Normal file
@ -0,0 +1,3 @@
|
||||
Acquire::http::Proxy "http://proxy:3128/";
|
||||
Acquire::https::Proxy "http://proxy:3128/";
|
||||
|
2
tests/files/etc/environment
Normal file
2
tests/files/etc/environment
Normal file
@ -0,0 +1,2 @@
|
||||
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
|
||||
HTTP_PROXY="http://proxy:3128"
|
34
tests/files/etc/squid/squid.conf
Normal file
34
tests/files/etc/squid/squid.conf
Normal file
@ -0,0 +1,34 @@
|
||||
acl localhost src 127.0.0.1/32 ::1
|
||||
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
|
||||
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
|
||||
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
|
||||
acl SSL_ports port 443
|
||||
acl Safe_ports port 80 # http
|
||||
acl Safe_ports port 21 # ftp
|
||||
acl Safe_ports port 443 # https
|
||||
acl Safe_ports port 70 # gopher
|
||||
acl Safe_ports port 210 # wais
|
||||
acl Safe_ports port 1025-65535 # unregistered ports
|
||||
acl Safe_ports port 280 # http-mgmt
|
||||
acl Safe_ports port 488 # gss-http
|
||||
acl Safe_ports port 591 # filemaker
|
||||
acl Safe_ports port 777 # multiling http
|
||||
acl CONNECT method CONNECT
|
||||
http_access allow manager localhost
|
||||
http_access deny manager
|
||||
http_access deny !Safe_ports
|
||||
http_access deny CONNECT !SSL_ports
|
||||
http_access allow localnet
|
||||
http_access allow localhost
|
||||
http_access deny all
|
||||
http_port 3128
|
||||
maximum_object_size 2048 MB
|
||||
cache_dir aufs /var/spool/squid 5000 24 256
|
||||
coredump_dir /var/spool/squid
|
||||
refresh_pattern ^ftp: 1440 20% 10080
|
||||
refresh_pattern ^gopher: 1440 0% 1440
|
||||
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
|
||||
refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880
|
||||
refresh_pattern . 0 20% 4320
|
||||
refresh_all_ims on
|
||||
|
@ -5,6 +5,29 @@
|
||||
become: no
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Copy environmnet file
|
||||
copy:
|
||||
src: etc/environment
|
||||
dest: /tmp/environment
|
||||
- name: Copy Squid config
|
||||
copy:
|
||||
src: etc/squid/squid.conf
|
||||
dest: /tmp/squid.conf
|
||||
- name: Create a network
|
||||
docker_network:
|
||||
name: MongoDBTestingNet
|
||||
- name: Run Proxy in Docker
|
||||
docker_container:
|
||||
name: proxy
|
||||
image: sameersbn/squid
|
||||
state: started
|
||||
volumes:
|
||||
- /tmp/squid.conf:/etc/squid/squid.conf:ro
|
||||
networks:
|
||||
- name: MongoDBTestingNet
|
||||
aliases:
|
||||
- proxy
|
||||
networks_cli_compatible: yes
|
||||
- name: Run MongoDB cluster in Docker
|
||||
docker_container:
|
||||
name: "{{ item }}"
|
||||
@ -23,11 +46,35 @@
|
||||
target: /run
|
||||
- type: tmpfs
|
||||
target: /run/lock
|
||||
volumes:
|
||||
- /tmp/environment:/etc/environment:ro
|
||||
networks:
|
||||
- name: MongoDBTestingNet
|
||||
aliases:
|
||||
- "{{ item }}"
|
||||
networks_cli_compatible: yes
|
||||
with_items:
|
||||
- mongo1
|
||||
- mongo2
|
||||
- mongo3
|
||||
|
||||
- hosts: mongo
|
||||
become: no
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- name: Set proxy for apt
|
||||
copy:
|
||||
src: etc/apt/apt.conf.d/proxy.conf
|
||||
dest: /etc/apt/apt.conf.d/proxy.conf
|
||||
when: ansible_os_family == "Debian"
|
||||
- name: Set proxy for yum
|
||||
ini_file:
|
||||
path: /etc/yum.conf
|
||||
section: main
|
||||
option: proxy
|
||||
value: http://proxy:3128
|
||||
when: ansible_os_family == "RedHat"
|
||||
|
||||
- hosts: mongo
|
||||
become: no
|
||||
gather_facts: no
|
||||
|
Loading…
x
Reference in New Issue
Block a user