Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/adblockplus/manifests/host.pp

Issue 29366814: Noissue - Fix adblockplus::host $ensure = "absent" support (Closed)
Patch Set: Noissue - Include $ensure = "absent" example in the host class documentation Created Dec. 5, 2016, 12:03 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | modules/private-stub/hiera/hosts.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # == Type: adblockplus::host 1 # == Type: adblockplus::host
2 # 2 #
3 # Manage host information for any node within the Adblock Plus infrastructure. 3 # Manage host information for any node within the Adblock Plus infrastructure.
4 # 4 #
5 # === Parameters: 5 # === Parameters:
6 # 6 #
7 # [*ensure*] 7 # [*ensure*]
8 # Whether to ensure any host-related resources being 'present' or 'absent'. 8 # Whether to ensure any host-related resources being 'present' or 'absent'.
9 # Note that implicit realization of embedded resources only takes place if 9 # Note that implicit realization of embedded resources only takes place if
10 # $ensure is 'absent'. 10 # $ensure is 'absent'.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 # 47 #
48 # # Global realization, i.e. when creating a node all others can access 48 # # Global realization, i.e. when creating a node all others can access
49 # realize(Host<|tag == 'adblockplus::host'|>) 49 # realize(Host<|tag == 'adblockplus::host'|>)
50 # realize(Sshkey<|tag == 'adblockplus::host'|>) 50 # realize(Sshkey<|tag == 'adblockplus::host'|>)
51 # 51 #
52 # # Addressing (meta-) parameters for re-using their values 52 # # Addressing (meta-) parameters for re-using their values
53 # $fqdn = getparam(Adblockplus::Host['node1'], 'fqdn') 53 # $fqdn = getparam(Adblockplus::Host['node1'], 'fqdn')
54 # $primary_ip = getparam(Host['node1'], 'ip') 54 # $primary_ip = getparam(Host['node1'], 'ip')
55 # $key_type = getparam(Sshkey['node1'], 'type') 55 # $key_type = getparam(Sshkey['node1'], 'type')
56 # 56 #
57 # # Resources associated with 'absent' hosts are always realized
58 # adblockplus::host {'node0':
59 # ensure => 'absent',
60 # }
61 #
57 define adblockplus::host ( 62 define adblockplus::host (
58 $ensure = 'present', 63 $ensure = 'present',
59 $fqdn = "$name.$adblockplus::authority", 64 $fqdn = "$name.$adblockplus::authority",
60 $groups = [], 65 $groups = [],
61 $ips, 66 $ips = [],
62 $public_key = undef, 67 $public_key = undef,
63 $role = undef, 68 $role = undef,
64 ) { 69 ) {
65 70
66 include adblockplus 71 include adblockplus
67 include stdlib 72 include stdlib
68 73
69 case $public_key { 74 case $public_key {
70 75
71 undef: { 76 undef: {
72 $sshkey_ensure = 'absent' 77 $sshkey_ensure = 'absent'
73 $sshkey_key = undef 78 $sshkey_key = undef
74 $sshkey_type = undef 79 $sshkey_type = undef
75 } 80 }
76 81
77 default: { 82 default: {
78 $sshkey_ensure = $ensure 83 $sshkey_ensure = $ensure
79 $sshkey = split($public_key, '\s+') 84 $sshkey = split($public_key, '\s+')
80 $sshkey_type = $sshkey[0] 85 $sshkey_type = $sshkey[0]
81 $sshkey_key = $sshkey[1] 86 $sshkey_key = $sshkey[1]
82 } 87 }
83 } 88 }
84 89
85 @host {$title: 90 @host {$title:
86 ensure => $ensure, 91 ensure => $ensure,
87 ip => pick($ips), 92 ip => pick($ips[0], '0.0.0.0'),
88 name => $fqdn, 93 name => $fqdn,
89 tag => ['adblockplus::host'], 94 tag => ['adblockplus::host'],
90 } 95 }
91 96
92 @sshkey {$title: 97 @sshkey {$title:
93 ensure => $sshkey_ensure, 98 ensure => $sshkey_ensure,
94 host_aliases => $ips, 99 host_aliases => $ips,
95 key => $sshkey_key, 100 key => $sshkey_key,
96 name => $fqdn, 101 name => $fqdn,
97 require => File['/etc/ssh/ssh_known_hosts'], 102 require => File['/etc/ssh/ssh_known_hosts'],
98 tag => ['adblockplus::host'], 103 tag => ['adblockplus::host'],
99 type => $sshkey_type, 104 type => $sshkey_type,
100 } 105 }
101 106
102 if $ensure == 'absent' { 107 if $ensure == 'absent' {
103 realize(Host[$title]) 108 realize(Host[$title])
104 realize(Sshkey[$title]) 109 realize(Sshkey[$title])
105 } 110 }
106 111
107 if $::role != undef and manifest_exists("adblockplus::host::$::role") { 112 if $::role != undef and manifest_exists("adblockplus::host::$::role") {
108 ensure_resource("adblockplus::host::$::role", $title, {name => $name}) 113 ensure_resource("adblockplus::host::$::role", $title, {name => $name})
109 } 114 }
110 } 115 }
OLDNEW
« no previous file with comments | « no previous file | modules/private-stub/hiera/hosts.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld