Grid環境構築用のChefリポジトリです。
Revision | 7cecfb1f0f11632f1ab0b74b06ab9946609f2d6c (tree) |
---|---|
Time | 2017-01-21 23:54:23 |
Author | whitestar <whitestar@gaea...> |
Commiter | whitestar |
adds the ['lxcs']['lxd']['config'] attribute.
@@ -1,5 +1,10 @@ | ||
1 | 1 | # lxcs CHANGELOG |
2 | 2 | |
3 | +0.1.4 | |
4 | +----- | |
5 | +- adds the `['lxcs']['lxd']['config']` attribute. | |
6 | +- adds the `['lxcs']['lxd']['verbose']` attribute. | |
7 | + | |
3 | 8 | 0.1.3 |
4 | 9 | ----- |
5 | 10 | - updates OS support. |
@@ -39,12 +39,14 @@ This cookbook sets up LinuxContainers.org products (LXC, LXD). | ||
39 | 39 | |`['lxcs']['lxc']['lxc-usernet']`|Array, String|Content (line strings or single string) in the `/etc/lxc/lxc-usernet`.|`[]`, See `attributes/default.rb`| |
40 | 40 | |`['lxcs']['lxc']['default.conf']`|Array, String|Default initial configuration (profile) file. Content (line strings or single string) in the `/etc/lxc/default.conf`.|See `attributes/default.rb`| |
41 | 41 | |`['lxcs']['lxc']['extra-default.conf']`|Hash|Additional container configuration (profile) files.|`{}`, See `attributes/default.rb`| |
42 | +|`['lxcs']['lxd']['verbose']`|Boolean|Verbose mode.|`false`| | |
42 | 43 | |`['lxcs']['lxd']['with_zfs']`|Boolean|with ZFS utility.|`false`| |
43 | 44 | |`['lxcs']['lxd']['users_allow']`|Array|Non-root users allowed to manage Linux containers on LXD.|`[]`| |
44 | 45 | |`['lxcs']['lxd']['init']['enabled']`|Boolean|execute lxd init or not|`false`| |
45 | 46 | |`['lxcs']['lxd']['init']['force']`|Boolean|re-execute lxd init forcely.|`false`| |
46 | 47 | |`['lxcs']['lxd']['init']['options']`|String|lxd init command options string.|`''`| |
47 | 48 | |`['lxcs']['lxd']['init']['trust_password_vault_item']`|Hash|derive LXD server trust password from Chef Vault.|`{}`, See `attributes/default.rb`| |
49 | +|`['lxcs']['lxd']['config']`|Hash|lxd configurations.|`{}`, See `attributes/default.rb`| | |
48 | 50 | |`['lxcs']['lxd']['network']`|Hash|lxd network configurations. Ubuntu >= 16.10|`{}`, See `attributes/default.rb`| |
49 | 51 | |`['lxcs']['lxd']['network_force_update']`|Boolean|update lxd network configuration forcely.|`false`| |
50 | 52 | |`['lxcs']['lxd']['bridge']['enabled']`|Boolean|lxd bridge network configurations. Ubuntu <= 16.04|`false`| |
@@ -170,6 +172,9 @@ override_attributes( | ||
170 | 172 | #'--trust-password secret', |
171 | 173 | ].join(' '), |
172 | 174 | }, |
175 | + 'config' => { | |
176 | + 'core.https_address' => '192.168.1.50:8443', | |
177 | + }, | |
173 | 178 | # Ubuntu >= 16.10 |
174 | 179 | 'network' => { |
175 | 180 | 'lxdbr0' => { |
@@ -73,6 +73,7 @@ default['lxcs']['lxc']['lxc-usernet'] = [ | ||
73 | 73 | # ... |
74 | 74 | ] |
75 | 75 | |
76 | +default['lxcs']['lxd']['verbose'] = false | |
76 | 77 | default['lxcs']['lxd']['with_zfs'] = false |
77 | 78 | default['lxcs']['lxd']['users_allow'] = [] |
78 | 79 | default['lxcs']['lxd']['init'] = { |
@@ -117,6 +118,12 @@ Init options for non-interactive mode (--auto): | ||
117 | 118 | Password required to add new clients |
118 | 119 | =end |
119 | 120 | } |
121 | +default['lxcs']['lxd']['config'] = { | |
122 | +=begin | |
123 | + # Examples | |
124 | + 'core.https_address' => '192.168.1.50:8443', | |
125 | +=end | |
126 | +} | |
120 | 127 | # Ubuntu >= 16.10 (yakkety) |
121 | 128 | default['lxcs']['lxd']['network'] = { |
122 | 129 | =begin |
@@ -5,7 +5,7 @@ maintainer_email '' | ||
5 | 5 | license 'Apache 2.0' |
6 | 6 | description 'Installs/Configures LinuxContainers.org products' |
7 | 7 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) |
8 | -version '0.1.3' | |
8 | +version '0.1.4' | |
9 | 9 | source_url 'http://scm.osdn.jp/gitroot/metasearch/grid-chef-repo.git' |
10 | 10 | issues_url 'https://osdn.jp/projects/metasearch/ticket' |
11 | 11 |
@@ -71,7 +71,7 @@ if lxd_conf['init']['enabled'] | ||
71 | 71 | sensitive_init = opts =~ /--trust-password\s+/ ? true : false |
72 | 72 | |
73 | 73 | init_command = "lxd init --auto #{opts}" |
74 | - log "lxd init command: #{init_command}" unless sensitive_init | |
74 | + log "lxd init command: #{init_command}" if node['lxcs']['lxd']['verbose'] && !sensitive_init | |
75 | 75 | # Use bash resource to prevent the command string from being logged. |
76 | 76 | bash 'lxd_init' do |
77 | 77 | code init_command |
@@ -105,6 +105,34 @@ if lxd_conf['init']['enabled'] | ||
105 | 105 | end |
106 | 106 | end |
107 | 107 | |
108 | +# Base configurations | |
109 | +unless lxd_conf['config'].empty? | |
110 | + require 'yaml' | |
111 | + config_hash = lxd_conf['config'].to_hash | |
112 | + config_hash = { | |
113 | + 'config' => config_hash, | |
114 | + } | |
115 | + config_yaml = config_hash.to_yaml | |
116 | + log "lxd config: #{config_yaml}" if node['lxcs']['lxd']['verbose'] | |
117 | + | |
118 | + config_yaml_file = '/etc/lxd/config_by_chef.yml' | |
119 | + config_edit_exec_name = 'lxc_config_edit' | |
120 | + | |
121 | + execute config_edit_exec_name do | |
122 | + command "cat #{config_yaml_file} | lxc config edit --force-local" | |
123 | + action :nothing | |
124 | + end | |
125 | + | |
126 | + file config_yaml_file do | |
127 | + content "#{config_yaml}\n" # prevent noeol | |
128 | + owner 'root' | |
129 | + group 'root' | |
130 | + mode '0644' | |
131 | + action :create | |
132 | + notifies :run, "execute[#{config_edit_exec_name}]", :immediately | |
133 | + end | |
134 | +end | |
135 | + | |
108 | 136 | # Network setup |
109 | 137 | platfrom_version = node['platform_version'] |
110 | 138 | if platfrom_version >= '16.10' |
@@ -113,7 +141,7 @@ if platfrom_version >= '16.10' | ||
113 | 141 | net_hash = hash.to_hash |
114 | 142 | net_hash['name'] = net_name |
115 | 143 | net_yaml = net_hash.to_yaml |
116 | - log "lxd network config: #{net_yaml}" | |
144 | + log "lxd network config: #{net_yaml}" if node['lxcs']['lxd']['verbose'] | |
117 | 145 | |
118 | 146 | opts = [] |
119 | 147 | hash['config'].each {|key, value| |
@@ -176,7 +204,7 @@ lxd_conf['profile'].each {|prof_name, hash| | ||
176 | 204 | prof_hash = hash.to_hash |
177 | 205 | prof_hash['name'] = prof_name |
178 | 206 | prof_yaml = prof_hash.to_yaml |
179 | - log "lxd profile config: #{prof_yaml}" | |
207 | + log "lxd profile config: #{prof_yaml}" if node['lxcs']['lxd']['verbose'] | |
180 | 208 | |
181 | 209 | # create initially only once. |
182 | 210 | execute "lxc_profile_create_#{prof_name}" do |