Skip to content

Instantly share code, notes, and snippets.

@yaasita
Created August 16, 2019 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaasita/f3f8deb39d1f2a1c1b1e6df204ab98da to your computer and use it in GitHub Desktop.
Save yaasita/f3f8deb39d1f2a1c1b1e6df204ab98da to your computer and use it in GitHub Desktop.
snippet template
template "${1:#:condition}" do
source "script.erb"
owner "root"
group "root"
mode "0644"
variables(
:dbname => node['hoge']['mysql_create_database'],
:dbuser => node['hoge']['mysql_create_database'],
:dbpass => node['hoge']['mysql_create_database'],
:unicorn_processes => node['hoge']['unicorn_processes']
)
end
snippet package
package "${1:#condition}" do
action :install
end
snippet execute
execute "${1:#condition}" do
action :nothing
command "update-rc.d #{app_name} defaults"
end
snippet directory
directory "${1:#condition}" do
owner app_user
group app_user
mode 0755
action :create
end
snippet service
service "${1:#condition}" do
supports status: true, restart: true, reload: true
end
snippet bash
bash "${1:#condition}" do
user createuser
cwd "/home/#{createuser}"
not_if "test -d /home/#{createuser}/.rbenv"
code <<-EOH
export HOME=/home/#{createuser}
git clone git://github.com/sstephenson/rbenv.git .rbenv
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
mkdir -p ~/.rbenv/plugins
cd ~/.rbenv/plugins
git clone git://github.com/sstephenson/ruby-build.git
rbenv install #{node['hoge']['rbenv_version']}
rbenv global #{node['hoge']['rbenv_version']}
rbenv rehash
gem install bundle
EOH
end
snippet user
user "${1:#condition}" do
home "/home/#{createuser}"
supports :manage_home => true
shell "/bin/bash"
action :create
end
snippet default
default['yama']['add_install_package']=[]
snippet notifies
notifies :restart, "service[nagios-nrpe-server]"
snippet include_recipe
include_recipe "hoge-database"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment