vagrant-docker-mirror-config 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +11 -0
- data/LICENSE +5 -0
- data/README.md +25 -0
- data/Rakefile +3 -0
- data/Vagrantfile +74 -0
- data/lib/vagrant-docker-mirror-config.rb +11 -0
- data/lib/vagrant-docker-mirror-config/config.rb +30 -0
- data/lib/vagrant-docker-mirror-config/docker_mirror_config.rb +31 -0
- data/lib/vagrant-docker-mirror-config/plugin.rb +20 -0
- data/lib/vagrant-docker-mirror-config/provisioner.rb +21 -0
- data/lib/vagrant-docker-mirror-config/version.rb +5 -0
- data/vagrant-docker-mirror-config.gemspec +19 -0
- metadata +55 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b9462220b04150afb1328b5c2a31bd975cd36afc
|
4
|
+
data.tar.gz: db95ea00841ae1812c2c1ce2aefc097c1471049a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2df702a31aeecd424f42549686ab6873025599d078a7101f0f032f9bc261d44178df1a1649e92fd03d1a35b1db85063afe8bf47a28a98b38a622d550f0624b69
|
7
|
+
data.tar.gz: 65dfc13dc5f8e3b56cf30a1a99606ebda1c95a5ee02407dcf5d713563213e6f20a6785e00e59ce2c0cd081ec2de46ef0eaa0b415588de8607488fa8cdea8049a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
Copyright (c) 2016, Leigh McCulloch
|
2
|
+
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
4
|
+
|
5
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Vagrant Provisioner: Docker Mirror config
|
2
|
+
|
3
|
+
A Vagrant provisioner for setup a remote docker mirror.
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
```bash
|
8
|
+
vagrant plugin install vagrant-docker-mirror-config
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
Vagrant.configure("2") do |config|
|
15
|
+
config.vm.box = "debian/jessie64"
|
16
|
+
|
17
|
+
config.vm.provision :docker
|
18
|
+
config.vm.provision :docker_mirror_config, :host => "192.168.1.2", :port => 5001, :insecure => true, :tls => true
|
19
|
+
end
|
20
|
+
|
21
|
+
You can also use following environment variables :
|
22
|
+
* `DOCKER_DOCKER_MIRROR_TLS` optionnal, default is disabled
|
23
|
+
* `DOCKER_DOCKER_MIRROR_HOST` required
|
24
|
+
* `DOCKER_DOCKER_MIRROR_PORT` optionnal, default is 5000
|
25
|
+
* `DOCKER_DOCKER_MIRROR_INSECURE` optional, default is false
|
data/Rakefile
ADDED
data/Vagrantfile
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
# All Vagrant configuration is done below. The "2" in Vagrant.configure
|
5
|
+
# configures the configuration version (we support older styles for
|
6
|
+
# backwards compatibility). Please don't change it unless you know what
|
7
|
+
# you're doing.
|
8
|
+
Vagrant.configure("2") do |config|
|
9
|
+
# The most common configuration options are documented and commented below.
|
10
|
+
# For a complete reference, please see the online documentation at
|
11
|
+
# https://docs.vagrantup.com.
|
12
|
+
|
13
|
+
# Every Vagrant development environment requires a box. You can search for
|
14
|
+
# boxes at https://atlas.hashicorp.com/search.
|
15
|
+
config.vm.box = "debian/jessie64"
|
16
|
+
|
17
|
+
config.vm.provision :docker
|
18
|
+
config.vm.provision :docker_mirror_config, :host => "192.168.1.2", :port => 5001, :insecure => true, :tls => true
|
19
|
+
|
20
|
+
# Disable automatic box update checking. If you disable this, then
|
21
|
+
# boxes will only be checked for updates when the user runs
|
22
|
+
# `vagrant box outdated`. This is not recommended.
|
23
|
+
# config.vm.box_check_update = false
|
24
|
+
|
25
|
+
# Create a forwarded port mapping which allows access to a specific port
|
26
|
+
# within the machine from a port on the host machine. In the example below,
|
27
|
+
# accessing "localhost:8080" will access port 80 on the guest machine.
|
28
|
+
# config.vm.network "forwarded_port", guest: 80, host: 8080
|
29
|
+
|
30
|
+
# Create a private network, which allows host-only access to the machine
|
31
|
+
# using a specific IP.
|
32
|
+
# config.vm.network "private_network", ip: "192.168.33.10"
|
33
|
+
|
34
|
+
# Create a public network, which generally matched to bridged network.
|
35
|
+
# Bridged networks make the machine appear as another physical device on
|
36
|
+
# your network.
|
37
|
+
# config.vm.network "public_network"
|
38
|
+
|
39
|
+
# Share an additional folder to the guest VM. The first argument is
|
40
|
+
# the path on the host to the actual folder. The second argument is
|
41
|
+
# the path on the guest to mount the folder. And the optional third
|
42
|
+
# argument is a set of non-required options.
|
43
|
+
# config.vm.synced_folder "../data", "/vagrant_data"
|
44
|
+
|
45
|
+
# Provider-specific configuration so you can fine-tune various
|
46
|
+
# backing providers for Vagrant. These expose provider-specific options.
|
47
|
+
# Example for VirtualBox:
|
48
|
+
#
|
49
|
+
# config.vm.provider "virtualbox" do |vb|
|
50
|
+
# # Display the VirtualBox GUI when booting the machine
|
51
|
+
# vb.gui = true
|
52
|
+
#
|
53
|
+
# # Customize the amount of memory on the VM:
|
54
|
+
# vb.memory = "1024"
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
# View the documentation for the provider you are using for more
|
58
|
+
# information on available options.
|
59
|
+
|
60
|
+
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
|
61
|
+
# such as FTP and Heroku are also available. See the documentation at
|
62
|
+
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
|
63
|
+
# config.push.define "atlas" do |push|
|
64
|
+
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
|
65
|
+
# end
|
66
|
+
|
67
|
+
# Enable provisioning with a shell script. Additional provisioners such as
|
68
|
+
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
|
69
|
+
# documentation for more information about their specific syntax and use.
|
70
|
+
# config.vm.provision "shell", inline: <<-SHELL
|
71
|
+
# apt-get update
|
72
|
+
# apt-get install -y apache2
|
73
|
+
# SHELL
|
74
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module DockerMirrorConfigProvisioner
|
3
|
+
|
4
|
+
class ConfigError < Vagrant::Errors::VagrantError
|
5
|
+
end
|
6
|
+
|
7
|
+
class Config < Vagrant.plugin("2", :config)
|
8
|
+
attr_accessor :tls, :host, :port, :scheme, :insecure
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@tls = false
|
12
|
+
@host = UNSET_VALUE
|
13
|
+
@port = 5000
|
14
|
+
@scheme = "http"
|
15
|
+
@insecure = false
|
16
|
+
end
|
17
|
+
|
18
|
+
def finalize!
|
19
|
+
@tls = true if ENV["DOCKER_MIRROR_TLS"] == "yes"
|
20
|
+
@host = ENV["DOCKER_MIRROR_HOST"] if @host == UNSET_VALUE
|
21
|
+
@port = ENV["DOCKER_MIRROR_PORT"] if ENV["DOCKER_MIRROR_PORT"]
|
22
|
+
@insecure = true if ENV["DOCKER_MIRROR_INSECURE"] == "yes"
|
23
|
+
@scheme = "https" if @tls
|
24
|
+
@scheme = "http" if not @tls
|
25
|
+
|
26
|
+
raise ConfigError.new(:host_undefined, "Undefined") if not @host
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module DockerMirrorConfigProvisioner
|
5
|
+
class DockerMirrorConfig
|
6
|
+
def initialize(machine, config)
|
7
|
+
@machine = machine
|
8
|
+
@config = config
|
9
|
+
end
|
10
|
+
|
11
|
+
def configure
|
12
|
+
@machine.communicate.tap do |comm|
|
13
|
+
#comm.sudo("cp /lib/systemd/system/docker.service /etc/systemd/system/docker.service")
|
14
|
+
comm.sudo("mkdir -p /etc/systemd/system/docker.service.d/")
|
15
|
+
comm.sudo("mkdir -p /etc/sysconfig")
|
16
|
+
options = "DOCKER_OPTS=\""
|
17
|
+
options += " --registry-mirror #{@config.scheme}://#{@config.host}:#{@config.port}"
|
18
|
+
options += " --insecure-registry #{@config.host}:#{@config.port}" if @config.insecure
|
19
|
+
options += "\""
|
20
|
+
comm.sudo("echo #{options} > /etc/sysconfig/docker")
|
21
|
+
comm.sudo("echo [Service] > /etc/systemd/system/docker.service.d/docker.conf")
|
22
|
+
comm.sudo("echo EnvironmentFile=-/etc/sysconfig/docker >> /etc/systemd/system/docker.service.d/docker.conf")
|
23
|
+
comm.sudo("echo ExecStart= >> /etc/systemd/system/docker.service.d/docker.conf")
|
24
|
+
comm.sudo("echo ExecStart=/usr/bin/docker daemon -H fd:// \\\$DOCKER_OPTS >> /etc/systemd/system/docker.service.d/docker.conf")
|
25
|
+
comm.sudo("systemctl daemon-reload")
|
26
|
+
comm.sudo("systemctl restart docker")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module DockerMirrorConfigProvisioner
|
3
|
+
class Plugin < Vagrant.plugin("2")
|
4
|
+
name "vagrant-docker-mirror-config"
|
5
|
+
description <<-DESC
|
6
|
+
Provides support for provisioning your virtual machines that run Docker, by configuring reachable mirrors.
|
7
|
+
DESC
|
8
|
+
|
9
|
+
config(:docker_mirror_config, :provisioner) do
|
10
|
+
require_relative "config"
|
11
|
+
Config
|
12
|
+
end
|
13
|
+
|
14
|
+
provisioner(:docker_mirror_config) do
|
15
|
+
require_relative "provisioner"
|
16
|
+
Provisioner
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative "docker_mirror_config"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module DockerMirrorConfigProvisioner
|
5
|
+
class Provisioner < Vagrant.plugin("2", :provisioner)
|
6
|
+
def initialize(machine, config)
|
7
|
+
super(machine, config)
|
8
|
+
@docker_mirror = DockerMirrorConfig.new(@machine, @config)
|
9
|
+
end
|
10
|
+
|
11
|
+
def provision
|
12
|
+
@machine.ui.info("Configuring docker mirror")
|
13
|
+
@machine.ui.info(" -> Host : #{@config.host}")
|
14
|
+
@machine.ui.info(" -> Port : #{@config.port}")
|
15
|
+
@machine.ui.info(" -> TLS : #{@config.tls}")
|
16
|
+
@machine.ui.info(" -> Insecure : #{@config.insecure}")
|
17
|
+
@docker_mirror.configure
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require "vagrant-docker-mirror-config/version"
|
7
|
+
|
8
|
+
Gem::Specification.new do |s|
|
9
|
+
s.name = "vagrant-docker-mirror-config"
|
10
|
+
s.version = VagrantPlugins::DockerMirrorConfigProvisioner::VERSION
|
11
|
+
s.platform = Gem::Platform::RUBY
|
12
|
+
s.authors = ["Geoffrey Ragot"]
|
13
|
+
s.homepage = "https://github.com/gfyrag/vagrant-docker-mirror-config"
|
14
|
+
s.summary = %q{A Vagrant provisioner for configuring mirror for docker.}
|
15
|
+
s.description = %q{A Vagrant provisioner for configuring mirror for docker.}
|
16
|
+
|
17
|
+
s.files = `git ls-files -z`.split("\0")
|
18
|
+
s.require_path = "lib"
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-docker-mirror-config
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Geoffrey Ragot
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-13 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A Vagrant provisioner for configuring mirror for docker.
|
14
|
+
email:
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- ".gitignore"
|
20
|
+
- Gemfile
|
21
|
+
- LICENSE
|
22
|
+
- README.md
|
23
|
+
- Rakefile
|
24
|
+
- Vagrantfile
|
25
|
+
- lib/vagrant-docker-mirror-config.rb
|
26
|
+
- lib/vagrant-docker-mirror-config/config.rb
|
27
|
+
- lib/vagrant-docker-mirror-config/docker_mirror_config.rb
|
28
|
+
- lib/vagrant-docker-mirror-config/plugin.rb
|
29
|
+
- lib/vagrant-docker-mirror-config/provisioner.rb
|
30
|
+
- lib/vagrant-docker-mirror-config/version.rb
|
31
|
+
- vagrant-docker-mirror-config.gemspec
|
32
|
+
homepage: https://github.com/gfyrag/vagrant-docker-mirror-config
|
33
|
+
licenses: []
|
34
|
+
metadata: {}
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
requirements: []
|
50
|
+
rubyforge_project:
|
51
|
+
rubygems_version: 2.5.1
|
52
|
+
signing_key:
|
53
|
+
specification_version: 4
|
54
|
+
summary: A Vagrant provisioner for configuring mirror for docker.
|
55
|
+
test_files: []
|