Skip to content

Commit

Permalink
Merge pull request #21 from sue445/feature/dockerlize
Browse files Browse the repository at this point in the history
Dockerlize
  • Loading branch information
sue445 committed Apr 18, 2018
2 parents 7cb75d1 + 73a9362 commit 800b335
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 266 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -7,4 +7,3 @@
/pkg/
/spec/reports/
/tmp/
.vagrant/
26 changes: 26 additions & 0 deletions .travis.yml
@@ -0,0 +1,26 @@
language: ruby
sudo: required
services:
- docker
rvm:
- 2.3
env:
- IMAGE=centos:7
- IMAGE=debian:jessie
bundler_args: "--jobs=4"
cache: bundler
before_install:
- gem update --system --no-document
- gem install bundler --no-document
before_script:
- docker run --privileged -d --name container-with-service $IMAGE /sbin/init
script:
- bundle exec itamae docker --node-yaml=recipes/node.yml recipes/install.rb --container=container-with-service --tag itamae-plugin:latest
- DOCKER_CONTAINER=container-with-service bundle exec rspec
branches:
only:
- master
notifications:
email: false
slack:
secure: M93HeWW+fQk+PrzI2mdtnlVkpiMVfQcfujFXl76ly0EtLS3V9p5KKHSyduQ2t7j/KOoRVF+86sEdPZJg16Ha+Y9pVE2oAs7SMv57rT9HaoQtzf5kZo64eCy63+iV+jUZ4U+NitrtNM1vELKyOsSgAq/KJblq9U67Wto3lOsRec7rskwlkjRwqV4TQElqbA1h4oyWyQG0SMKNnmKYV6TFC0/UNjnYLkxNY3btcOB/PYURxfcwbZk9IU+7id2MM4uG8cBVGSjqOglYOWdpWxTCJpZ6YQGdmXsICa38D/Y3crEHLcUAE4DkaPHpTSVdjVm0kvQlUDuLOmHe+Eh4lm6zy8NCMpyO80/C74/OQQdQgDkohKFI8RX/BZnKdQAmZZf8cIdfe4pF4cZGB8mzGcBcpSBApQHEXZyuJF5u9clNW6+Cdo8jtps0c7Nqg3NWebpUCqwiTVR95Dr820sO6wtIlqlNB5AaNpHzefFoxd42pRm5+Ua9rDuoDuRyhVuWcUQCOn9ScqjhsY9q1UIRbgF03ILgDFmFTu/ClaJ7tOtAtE9n7IsibNf87o2Lz+rNQUrIzIZUo7vElrCub0RhgZFy9+sfplHyIR5CBD4y/9Ca6KoB06vzyb3Y7ElXwIifwbGQ3EQZdAWV6V7slVP83+ahHD+K0E+EPLzAqaDum0MkeqI=
13 changes: 5 additions & 8 deletions README.md
Expand Up @@ -3,10 +3,9 @@
Itamae plugin to install [Consul](https://www.consul.io/) with init scripts

[![Gem Version](https://badge.fury.io/rb/itamae-plugin-recipe-consul.svg)](https://badge.fury.io/rb/itamae-plugin-recipe-consul)
[![Build Status](https://travis-ci.org/sue445/itamae-plugin-recipe-consul.svg?branch=master)](https://travis-ci.org/sue445/itamae-plugin-recipe-consul)
[![Dependency Status](https://gemnasium.com/badges/github.com/sue445/itamae-plugin-recipe-consul.svg)](https://gemnasium.com/github.com/sue445/itamae-plugin-recipe-consul)

[![wercker status](https://app.wercker.com/status/1d28d36364b4f79161fc248c6c934072/m/master "wercker status")](https://app.wercker.com/project/bykey/1d28d36364b4f79161fc248c6c934072)

## Supported
* CentOS 6 (init.d)
* CentOS 7+ (systemd)
Expand Down Expand Up @@ -87,18 +86,16 @@ After checking out the repo, run `bin/setup` to install dependencies. You can al
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Testing
requirements [Vagrant](https://www.vagrantup.com/)
requirements [Docker](https://www.docker.com/)

e.g) test on CentOS 7.0

```sh
vagrant up centos7
bundle exec rake itamae:centos7
bundle exec rake spec:centos7
docker run --privileged -d --name container-with-service centos:7 /sbin/init
bundle exec itamae docker --node-yaml=recipes/node.yml recipes/install.rb --container=container-with-service --tag itamae-plugin:latest
DOCKER_CONTAINER=container-with-service bundle exec rspec
```

Avairable hosts are defined in [Vagrantfile](Vagrantfile) and [Rakefile](Rakefile)

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/sue445/itamae-plugin-recipe-consul.
Expand Down
29 changes: 0 additions & 29 deletions Rakefile
@@ -1,30 +1 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"

task :spec => "spec:all"

HOSTS = %w(centos7 debian8)

namespace :spec do
task :all => HOSTS

HOSTS.each do |host|
desc "Run serverspec to #{host}"
RSpec::Core::RakeTask.new(host.to_sym) do |t|
puts "Running tests to #{host} ..."
ENV["TARGET_HOST"] = host
t.pattern = "spec/**/*_spec.rb"
end
end
end

namespace :itamae do
task :all => HOSTS

HOSTS.each do |host|
desc "Run itamae to #{host}"
task host do
sh "itamae ssh --host=#{host} --vagrant --node-yaml=recipes/node.yml recipes/install.rb"
end
end
end
106 changes: 0 additions & 106 deletions Vagrantfile

This file was deleted.

7 changes: 0 additions & 7 deletions ci/build.sh

This file was deleted.

25 changes: 0 additions & 25 deletions ci/setup.sh

This file was deleted.

1 change: 1 addition & 0 deletions itamae-plugin-recipe-consul.gemspec
Expand Up @@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "itamae"

spec.add_development_dependency "bundler"
spec.add_development_dependency "docker-api"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "serverspec"
end
5 changes: 5 additions & 0 deletions recipes/install.rb
@@ -1 +1,6 @@
case node[:platform]
when "debian", "ubuntu"
execute "apt-get update"
end

include_recipe "consul"
34 changes: 5 additions & 29 deletions spec/spec_helper.rb
@@ -1,41 +1,17 @@
require 'serverspec'
require 'net/ssh'
require 'tempfile'

set :backend, :ssh

if ENV['ASK_SUDO_PASSWORD']
begin
require 'highline/import'
rescue LoadError
fail "highline is not available. Try installing it."
end
set :sudo_password, ask("Enter sudo password: ") { |q| q.echo = false }
else
set :sudo_password, ENV['SUDO_PASSWORD']
end

host = ENV['TARGET_HOST']

`vagrant up #{host}`

config = Tempfile.new('', Dir.tmpdir)
config.write(`vagrant ssh-config #{host}`)
config.close

options = Net::SSH::Config.for(host, [config.path])
require 'docker'

options[:user] ||= Etc.getlogin
set :backend, :docker

set :host, options[:host_name] || host
set :ssh_options, options
set :docker_image, ENV['DOCKER_IMAGE']
set :docker_container, ENV['DOCKER_CONTAINER']

# Disable sudo
# set :disable_sudo, true


# Set environment variables
# set :env, :LANG => 'C', :LC_MESSAGES => 'C'
# set :env, :LANG => 'C', :LC_MESSAGES => 'C'

# Set PATH
# set :path, '/sbin:/usr/local/sbin:$PATH'
Expand Down
61 changes: 0 additions & 61 deletions wercker.yml

This file was deleted.

0 comments on commit 800b335

Please sign in to comment.