Giter VIP home page Giter VIP logo

itamae's Introduction

Gem Version Code Climate Build Status Slack

Simple and lightweight configuration management tool inspired by Chef.

Concept

  • Chef-like DSL (but not compatible with Chef)
  • Simpler and lighter weight than Chef
  • Only recipes
  • Idempotent

Installation

$ gem install itamae

Getting Started

Create a recipe file as recipe.rb:

package 'nginx' do
  action :install
end

service 'nginx' do
  action [:enable, :start]
end

And then execute itamae command to apply a recipe to a local machine.

$ itamae local recipe.rb
 INFO : Starting Itamae...
 INFO : Recipe: /home/user/recipe.rb
 INFO :    package[nginx]
 INFO :       action: install
 INFO :          installed will change from 'false' to 'true'
 INFO :    service[nginx]
 INFO :       action: enable
 INFO :       action: start

Or you can apply a recipe to a remote machine by itamae ssh.

$ itamae ssh --host host001.example.jp recipe.rb

You can also apply a recipe to Vagrant VM by itamae ssh --vagrant.

$ itamae ssh --vagrant --host vm_name recipe.rb

You can find further information to use Itamae on Itamae Wiki.

Enjoy!

Documentation

https://github.com/itamae-kitchen/itamae/wiki

Run tests

Requirements: Vagrant

$ bundle exec rake spec

Get Involved

Presentations / Articles

in Japanese

Contributing

If you have a problem, please create an issue or a pull request.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

itamae's People

Contributors

chaaaaarlotte avatar civitaspo avatar dependabot[bot] avatar eagletmt avatar eugene-jetruby avatar ganmacs avatar hfm avatar hico-horiuchi avatar k0kubun avatar kawakubox avatar kitaitimakoto avatar koshigoe avatar mizzy avatar mmasaki avatar muratayusuke avatar neidiom avatar nishidayuya avatar npoi avatar pocke avatar rrreeeyyy avatar ryotarai avatar sorah avatar sue445 avatar takus avatar terceiro avatar terut avatar toritori0318 avatar unasuke avatar uraura avatar yuichiro-naito avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

itamae's Issues

from_image method

Using Docker backend, recipes and base image are inseparable in most cases.

from_image "ubuntu:14.04"

execute "some command"

Implement resources.

  • package
  • directory
  • template
  • remote_file (similar to cookbook_file in Chef)
  • execute
  • local_ruby_block
  • service
  • user

run resource without name

I want to define a resource method

define install_something version: 'release' do
  execute 'install somethiong' do
  command<<-"EOS"
  git clone -b #{params[:version]} https://github.com/user/something
  cd something
  make
  make install
  EOS
  end
end

and, want to run without name like

install_something do
  version 'master'
end

.

What do you think of it and requirement of name @ryotarai ?

Implement only_if and not_if.

only_if and not_if accept shell command. (Lightchef cannot support ruby block)

execute 'install_something' do
  not_if 'which something'
end

diff(1) not found in CoreOS

With CoreOS stable (607.0.0) and Itamae v1.2.12, applying remote_file resource causes following error message because CoreOS doesn't have diff(1).

> itamae ssh -h coreos-01 roles/aws/coreos/default.rb
 INFO : Starting Itamae...
 INFO : Recipe: /Users/mirakui/src/itamae_recipes/roles/aws/coreos/default.rb
 INFO :   diff:
 INFO :   /bin/sh: diff: command not found

recipe:

remote_file '/usr/share/oem/cloud-config.yml' do
  owner 'root'
  group 'root'
  mode '0644'
  source 'files/cloud-config.yml'
end

but the applying succeeded.

Normalize attribute values before showing diff

user 'john' do
  uid '123'
  gid 'itamae' # the gid is 456
end
DEBUG[9af44ca1]      INFO :    user[john]
DEBUG[9af44ca1]      INFO :       action: create
DEBUG[9af44ca1]      INFO :          uid will change from '123' to '123'
DEBUG[9af44ca1]      INFO :          gid will change from '456' to 'itamae'

ln -sf

DEBUG [f43d9cc9]        ERROR :                Command `ln -s /usr/local/bin/consul-0.5.0 /usr/local/bin/consul` failed. (exit status: 1)
DEBUG [f43d9cc9]        ERROR :                stdout | ln: failed to create symbolic link '/usr/local/bin/consul': File exists

Supporting provider for service resource like chef

I want to have provider attribute for service resource which chef has.

In the chef, writing service resource like below allows us to change the service command to upstart.

service "example_service" do
  action :start
  provider Chef::Provider::Service::Upstart
  notifies :restart, "service[nginx]", :immediately
end

Also, with writing a gem like https://github.com/hirose31/chef-provider-service-daemontools, we add a provider Chef::Provider::Service::Daemontools to change the service commands to one of daemontools.

I am willing to implement this, but I want to disscuss the implementation design beforehand.

1) under way

Specinfra has some of check_is_running_under_#{provider} methods already like this, so one way would be to change lib/itamae/resource/service.rb as this patch > https://gist.github.com/sonots/0b601f610b04d2c27cdd. And, add xxx_under_xxx methods to specinfra.

2) module way

Specinfra has Specinfra::Command::Module::Systemd at lib/specinfra/command/module/systemd.rb, so one way would be to support to specify a module with provider attribute, and mixin it on calling run_specinfra by some ways.

3) resource way

Giving up to provide provider attribute, and implement the feature as another resource like

daemontools_service "foo" do
  action :start
end

I think this design is heavily related with the implementation design in specinfra, so it is better to discuss with both @mizzy and @ryotarai.

EDIT: I also want to have provider attribute for package resource like chef > https://docs.chef.io/resource_package.html. Chef allows us to specify provider Chef::Provider::Package::Rpm, also chef provides rpm_package resource in this case.

Please let me know if there is a discussion already.

Update file atomically.

  1. Copy target file to temp dir.
  2. Set permission, owner and so on.
  3. Move temp file to specific path.

image cache

To reduce time to build Docker image, cache images after each recipe provisioned.

`source :auto` of template and remote_file resource.

remote_file

remote_file "/etc/nginx/conf.d/itamae.conf" do
  source :auto # This is default
end

Itamae will search files/etc/nginx/conf.d/itamae.conf, files/nginx/conf.d/itamae.conf, files/conf.d/itamae.conf and files/itamae.conf under the directory where the recipe exists and use the file found first.

template

template "/etc/nginx/conf.d/itamae.conf" do
  source :auto # This is default
end

Itamae will search templates/etc/nginx/conf.d/itamae.conf.erb, templates/nginx/conf.d/itamae.conf.erb, templates/conf.d/itamae.conf.erb and templates/itamae.conf.erb under the directory where the recipe exists and use the file found first.

Node validation method.

node.validate!(:key1, :key2)

# if node[:key1][:key2] is not set:
# raise ValidationError, "node[:key1][:key2] must be set."

node.validate!(:key1, :key2, message: "can't be nil")
# if node[:key1][:key2] is not set:
# raise ValidationError, "node[:key1][:key2] can't be nil."

`action :stop` is not work for postgresql-9.3 on Ubuntu 14.04.3

action :stop is not work for postgresql-9.3 on Ubuntu 14.04.3.

service "postgresql" do
  action :stop
end

Because, service postgresql status not return "running"

$ sudo service postgresql status
9.3/main (port 5432): online

Temporary fix:

class Specinfra::Command::Ubuntu::Base::Service < Specinfra::Command::Debian::Base::Service
  class << self
    def check_is_running(service)
      "service #{escape(service)} status && service #{escape(service)} status | egrep 'running|online'"
    end
  end
end

`node.platform` return different value with/without `--ohai` option.

Hi, Thank you great tool !

But I have a question with --ohai option.

When I execute itamae without --ohai option to centos 6.5 (virtualbox), node.platform return redhat.
But, I execute itamae with --ohai option to same host, node.platform return centos.

Do you expect this behavior ?

I wonder that I can not write codes depend on node.platform in plugin.

Thanks.

Separate attributes set in a recipe and in pre_action

service "mysql" do
  action [:stop, :disable]
end
DEBUG :   service[mysql]
DEBUG :     service[mysql] action: stop
DEBUG :       (in show_differences)
INFO :       service[mysql] running will change from 'true' to 'false'
DEBUG :       service[mysql] enabled will not change (current value is 'true')
DEBUG :     service[mysql] action: disable
DEBUG :       (in show_differences)
INFO :       service[mysql] running will change from 'true' to 'false' # This should not appear
INFO :       service[mysql] enabled will change from 'true' to 'false'

defined resources ignores falsey arguments

define :awesome, flag: 'default' do
  p ["(^-^)/", params[:flag]]
end

awesome 'nil' do
  flag nil
end

awesome 'false' do
  flag false
end

awesome 'true' do
  flag true
end
 INFO : Starting Itamae...
["(^-^)/", "default"]
["(^-^)/", "default"]
["(^-^)/", true]
 INFO : Recipe: /tmp/define.rb

Can I use 'source' command in my resource class?

I tried run 'source' command using like this run_command(["source", "~/.bashrc"]), but I got the error below.

ERROR :     stdout | /bin/sh: 1: source: not found
ERROR :     Command `source \~/.bashrc` failed. (exit status: 127)

How can I solve this problem?

can I create drone-plugin for Itamae?

@ryotarai

Hi, I'm using drone-0.4-database (pre-release version of drone).

It has docker plugins for other systems such as slack for notification, docker for publish container image using Dockerfile.

and I want to create drone-itamae plugin for publish docker container.

Can I use itamae for drone-itamae?

Thank you.

Node attribute validation

like this:

node.validate do
  {
    profile: {
      name: required(String),
      age: optional(Integer),
      locations: optional(array_of(String)),
    },
  }
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.