From ec8f9e4be88d516837ff58a71acb0b3804ba9a99 Mon Sep 17 00:00:00 2001 From: Jaime Date: Thu, 24 Nov 2016 12:20:37 +0000 Subject: [PATCH 1/2] fix scope issues in classes and templates --- manifests/config.pp | 4 ++-- manifests/etcd_key.pp | 6 +++--- manifests/install.pp | 2 +- manifests/service.pp | 4 ++-- templates/etcd_network_definition.erb | 14 +++++++------- templates/sysconfig/flanneld.erb | 16 ++++++++-------- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 8b3a5d7..5d08fef 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -25,7 +25,7 @@ } if $::operatingsystemmajrelease == 7 { - if $flannel::manage_docker { + if $::flannel::manage_docker { $docker_dropin_ensure = 'file' include ::docker File['/usr/lib/systemd/system/docker.service.d/flannel.conf'] ~> Service['flanneld'] ~> Service['docker'] @@ -43,7 +43,7 @@ refreshonly => true, } - if $flannel::journald_forward_enable { + if $::flannel::journald_forward_enable { file { '/etc/systemd/system/flanneld.service.d': ensure => 'directory', owner => 'root', diff --git a/manifests/etcd_key.pp b/manifests/etcd_key.pp index a6c8222..f93f286 100644 --- a/manifests/etcd_key.pp +++ b/manifests/etcd_key.pp @@ -43,9 +43,9 @@ etcd_key { "${::flannel::etcd_prefix}/config": value => template('flannel/etcd_network_definition.erb'), peers => join($::flannel::etcd_endpoints, ','), - cert_file => $flannel::etcd_certfile, - key_file => $flannel::etcd_keyfile, - ca_file => $flannel::etcd_cafile, + cert_file => $::flannel::etcd_certfile, + key_file => $::flannel::etcd_keyfile, + ca_file => $::flannel::etcd_cafile, notify => Service['flanneld'], } } diff --git a/manifests/install.pp b/manifests/install.pp index 10b337a..2139313 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -1,4 +1,4 @@ # Installs default flannel packages class flannel::install { - package { [$flannel::package_name]: ensure => $flannel::ensure, } + package { [$::flannel::package_name]: ensure => $::flannel::ensure, } } diff --git a/manifests/service.pp b/manifests/service.pp index 0d46b81..23c64a5 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,7 +1,7 @@ # Takes care of starting flannel service class flannel::service { service { 'flanneld': - ensure => $flannel::service_state, - enable => $flannel::service_enable, + ensure => $::flannel::service_state, + enable => $::flannel::service_enable, } } diff --git a/templates/etcd_network_definition.erb b/templates/etcd_network_definition.erb index b939be5..9a6ad4b 100644 --- a/templates/etcd_network_definition.erb +++ b/templates/etcd_network_definition.erb @@ -1,22 +1,22 @@ { "Network": "<%= scope['flannel::etcd_key::network'] %>"<% -%> -<% if @subnetlen then -%>, +<% unless [nil, :undefined, :undef, ''].include?(scope['flannel::etcd_key::subnetlen']) -%>, "SubnetLen": <%= scope['flannel::etcd_key::subnetlen'] -%> <% end -%> -<% if @subnetmin then -%>, +<% unless [nil, :undefined, :undef, ''].include?(scope['flannel::etcd_key::subnetmin']) -%>, "SubnetMin": "<%= scope['flannel::etcd_key::subnetmin'] %>"<% -%> <% end -%> -<% if @subnetmax then -%>, +<% unless [nil, :undefined, :undef, ''].include?(scope['flannel::etcd_key::subnetmax']) -%>, "SubnetMax": "<%= scope['flannel::etcd_key::subnetmax'] %>"<% -%> <% end -%> -<% if @backend_type && @backend_port then -%>, +<% unless [nil, :undefined, :undef, ''].include?(scope['flannel::etcd_key::backend_type']) and [nil, :undefined, :undef, ''].include?(scope['flannel::etcd_key::backend_port']) -%>, "Backend": { "Type": "<%= scope['flannel::etcd_key::backend_type'] %>"<% -%> -<% if @backend_type == 'udp' then -%>, +<% if scope['flannel::etcd_key::backend_type'] == 'udp' then -%>, "Port": <%= scope['flannel::etcd_key::backend_port'] -%> -<% elsif @backend_type == 'vxlan' -%>, +<% elsif scope['flannel::etcd_key::backend_type'] == 'vxlan' -%>, "VNI": <%= scope['flannel::etcd_key::backend_port'] -%> -<% elsif @backend_type == 'aws-vpc' -%>, +<% elsif scope['flannel::etcd_key::backend_type'] == 'aws-vpc' -%>, "RouteTableID": <%= scope['flannel::etcd_key::backend_port'] -%> <% end -%> diff --git a/templates/sysconfig/flanneld.erb b/templates/sysconfig/flanneld.erb index 20a95dd..a4dee6e 100644 --- a/templates/sysconfig/flanneld.erb +++ b/templates/sysconfig/flanneld.erb @@ -10,31 +10,31 @@ FLANNEL_ETCD_KEY="<%= scope['flannel::etcd_prefix'] %>" # Any additional options that you want to pass FLANNEL_OPTIONS="<% -%> -alsologtostderr=<%= scope['flannel::alsologtostderr'] -%> -<% if @etcd_keyfile && @etcd_certfile && @etcd_cafile then -%> +<% unless [nil, :undefined, :undef, ''].include?(scope['flannel::etcd_cafile']) and [nil, :undefined, :undef, ''].include?(scope['flannel::etcd_certfile']) and [nil, :undefined, :undef, ''].include?(scope['flannel::etcd_keyfile']) -%> -etcd-cafile=<%= scope['flannel::etcd_cafile'] -%> -etcd-certfile=<%= scope['flannel::etcd_certfile'] -%> -etcd-keyfile=<%= scope['flannel::etcd_keyfile'] -%> <% end -%> -<% if @iface then -%> +<% unless [nil, :undefined, :undef, ''].include?(scope['flannel::iface']) -%> -iface=<%= scope['flannel::iface'] -%> <% end -%> -ip-masq=<%= scope['flannel::ip_masq'] -%> -<% if @listen then -%> +<% unless [nil, :undefined, :undef, ''].include?(scope['flannel::listen']) -%> -listen=<%= scope['flannel::listen'] -%> <% end -%> -<% if @log_dir then -%> +<% unless [nil, :undefined, :undef, ''].include?(scope['flannel::log_dir']) -%> -log_dir=<%= scope['flannel::log_dir'] -%> <% end -%> -<% if @networks then -%> +<% unless [nil, :undefined, :undef, ''].include?(scope['flannel::networks']) -%> -networks=<%= scope['flannel::networks'] -%> <% end -%> -<% if @public_ip then -%> +<% unless [nil, :undefined, :undef, ''].include?(scope['flannel::public_ip']) -%> -public-ip=<%= scope['flannel::public_ip'] -%> <% end -%> -<% if @remote then -%> +<% unless [nil, :undefined, :undef, ''].include?(scope['flannel::remote']) -%> -remote=<%= scope['flannel::remote'] -%> <% end -%> -<% if @remote_keyfile && @remote_certfile && @remote_cafile then -%> +<% unless [nil, :undefined, :undef, ''].include?(scope['flannel::remote_cafile']) and [nil, :undefined, :undef, ''].include?(scope['flannel::remote_certfile']) and [nil, :undefined, :undef, ''].include?(scope['flannel::remote_keyfile']) -%> -remote-cafile=<%= scope['flannel::remote_cafile'] -%> -remote-certfile=<%= scope['flannel::remote_certfile'] -%> -remote-keyfile=<%= scope['flannel::remote_keyfile'] -%> From d6247e963f3072c02801bc4676dee0b459667cbe Mon Sep 17 00:00:00 2001 From: Jaime Date: Thu, 24 Nov 2016 12:59:41 +0000 Subject: [PATCH 2/2] compare 'operatingsystemmajrelease' fact with string value --- manifests/config.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index 5d08fef..abcc7b5 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -24,7 +24,7 @@ mode => '0644', } - if $::operatingsystemmajrelease == 7 { + if $::operatingsystemmajrelease == '7' { if $::flannel::manage_docker { $docker_dropin_ensure = 'file' include ::docker