Fix documented ruby code blocks formatting
This commit is contained in:
72
README.md
72
README.md
@@ -162,34 +162,36 @@ Templates
|
|||||||
|
|
||||||
In `templates/freebsd/jail.conf.erb`:
|
In `templates/freebsd/jail.conf.erb`:
|
||||||
|
|
||||||
exec.start = "/bin/sh /etc/rc";
|
```ruby
|
||||||
exec.stop = "/bin/sh /etc/rc.shutdown";
|
exec.start = "/bin/sh /etc/rc";
|
||||||
exec.clean;
|
exec.stop = "/bin/sh /etc/rc.shutdown";
|
||||||
mount.devfs;
|
exec.clean;
|
||||||
allow.chflags;
|
mount.devfs;
|
||||||
|
allow.chflags;
|
||||||
|
|
||||||
path = "/var/jails/$name";
|
path = "/var/jails/$name";
|
||||||
|
|
||||||
<% @jails.each do |jail| -%>
|
<% @jails.each do |jail| -%>
|
||||||
<%= jail[:name] %> {
|
<%= jail[:name] %> {
|
||||||
interface "<%= @if %>";
|
interface "<%= @if %>";
|
||||||
ip4.addr = <%= jail[:addr4] %>;
|
ip4.addr = <%= jail[:addr4] %>;
|
||||||
}
|
}
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
Simple usage:
|
Simple usage:
|
||||||
|
|
||||||
INTERFACE = 're0'.freeze
|
INTERFACE = 're0'.freeze
|
||||||
JAILS = [{
|
JAILS = [{
|
||||||
name: 'freebsd-10r1',
|
name: 'freebsd-10r1',
|
||||||
src: true,
|
src: true,
|
||||||
addr4: '10.0.0.1'
|
addr4: '10.0.0.1'
|
||||||
}]
|
}]
|
||||||
|
|
||||||
task :jails_conf do
|
task :jails_conf do
|
||||||
conf = template 'freebsd/jail.conf', if: INTERFACE, jails: JAILS
|
conf = template 'freebsd/jail.conf', if: INTERFACE, jails: JAILS
|
||||||
file_write_once '/etc/jail.conf', conf
|
file_write_once '/etc/jail.conf', conf
|
||||||
end
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Macros
|
Macros
|
||||||
@@ -225,16 +227,17 @@ Sample recipe
|
|||||||
Based on the previous template example (FreeBSD jails.conf
|
Based on the previous template example (FreeBSD jails.conf
|
||||||
template):
|
template):
|
||||||
|
|
||||||
require 'producer/stdlib'
|
```ruby
|
||||||
|
require 'producer/stdlib'
|
||||||
|
|
||||||
JAILS_ROOT = '/var/jails'.freeze
|
JAILS_ROOT = '/var/jails'.freeze
|
||||||
ZROOT = 'tank/jails'.freeze
|
ZROOT = 'tank/jails'.freeze
|
||||||
INTERFACE = 're0'.freeze
|
INTERFACE = 're0'.freeze
|
||||||
SETS = {
|
SETS = {
|
||||||
base: '2b028a894d25711ad496762622a52d74b1e32ee04693ad1cf056e3ddcdc23975',
|
base: '2b028a894d25711ad496762622a52d74b1e32ee04693ad1cf056e3ddcdc23975',
|
||||||
src: 'f919287a5ef51d4f133f27c99c54f2e8054f408d3dd53bc60f4e233cc75ec03d'
|
src: 'f919287a5ef51d4f133f27c99c54f2e8054f408d3dd53bc60f4e233cc75ec03d'
|
||||||
}.freeze
|
}.freeze
|
||||||
JAILS = [
|
JAILS = [
|
||||||
{
|
{
|
||||||
name: 'freebsd-10r1',
|
name: 'freebsd-10r1',
|
||||||
src: true,
|
src: true,
|
||||||
@@ -245,9 +248,9 @@ template):
|
|||||||
src: true,
|
src: true,
|
||||||
addr4: '10.0.0.2'
|
addr4: '10.0.0.2'
|
||||||
}
|
}
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
task :freebsd_archives_fetch do
|
task :freebsd_archives_fetch do
|
||||||
SETS.keys.each { |set| condition { no_file? "/tmp/#{set}.txz"} }
|
SETS.keys.each { |set| condition { no_file? "/tmp/#{set}.txz"} }
|
||||||
|
|
||||||
SETS.each do |set, sum|
|
SETS.each do |set, sum|
|
||||||
@@ -257,14 +260,14 @@ template):
|
|||||||
sha256 -c #{sum} #{set}.txz
|
sha256 -c #{sum} #{set}.txz
|
||||||
eoh
|
eoh
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task :jails_fs_create do
|
task :jails_fs_create do
|
||||||
condition { no_sh "zfs list #{ZROOT}" }
|
condition { no_sh "zfs list #{ZROOT}" }
|
||||||
sh "zfs create -o mountpoint=#{JAILS_ROOT} -o compress=lz4 #{ZROOT}"
|
sh "zfs create -o mountpoint=#{JAILS_ROOT} -o compress=lz4 #{ZROOT}"
|
||||||
end
|
end
|
||||||
|
|
||||||
JAILS.each do |jail|
|
JAILS.each do |jail|
|
||||||
root = "#{JAILS_ROOT}/#{jail[:name]}"
|
root = "#{JAILS_ROOT}/#{jail[:name]}"
|
||||||
fs = "#{ZROOT}/#{jail[:name]}"
|
fs = "#{ZROOT}/#{jail[:name]}"
|
||||||
|
|
||||||
@@ -284,8 +287,8 @@ template):
|
|||||||
|
|
||||||
task :rc_conf do
|
task :rc_conf do
|
||||||
file_write_once "#{root}/etc/rc.conf", <<-eoh
|
file_write_once "#{root}/etc/rc.conf", <<-eoh
|
||||||
hostname=#{jail[:name]}
|
hostname=#{jail[:name]}
|
||||||
# ...
|
# ...
|
||||||
eoh
|
eoh
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -312,12 +315,13 @@ template):
|
|||||||
sh "chroot #{root} freebsd-update fetch install"
|
sh "chroot #{root} freebsd-update fetch install"
|
||||||
sh "zfs snapshot #{fs}@update"
|
sh "zfs snapshot #{fs}@update"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
task :jails_conf do
|
task :jails_conf do
|
||||||
conf = template 'freebsd/jail.conf', if: INTERFACE, jails: JAILS
|
conf = template 'freebsd/jail.conf', if: INTERFACE, jails: JAILS
|
||||||
file_write_once '/etc/jail.conf', conf
|
file_write_once '/etc/jail.conf', conf
|
||||||
end
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Similar or related code and tools
|
Similar or related code and tools
|
||||||
|
Reference in New Issue
Block a user