Skip to content
This repository was archived by the owner on Apr 30, 2024. It is now read-only.

Commit 888e20a

Browse files
committed
Added progress messages to capture conf
1 parent b798804 commit 888e20a

File tree

4 files changed

+76
-34
lines changed

4 files changed

+76
-34
lines changed

environments/production/manifests/site.pp

+29-21
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
node default {
1717
case $facts['os']['name'] {
1818
/[Rr]ed[Hh]at|[Cc]ent[OS|os]/: {include std_centos }
19+
/[Uu]buntu/: {include std_ubuntu }
1920
/[Dd]arwin/: {include std_mac }
2021
/[Ww]indows/: {include std_windows}
2122
default: {include common }
@@ -26,34 +27,27 @@
2627
include common
2728
}
2829

29-
node szabo1 {
30-
include common
31-
include graylog
32-
include sssd
33-
include mount_drives
34-
include privileges
35-
}
36-
37-
node /matt/ {
38-
include common
39-
include sssd
40-
include graylog
41-
}
42-
4330
node /biobankdb/ {
4431
include common
4532
include sssd
4633
include graylog
4734
include dummy_login
4835
}
4936

50-
# Matches all of the lens machines for Huilin's team
51-
node /^lens\d+$/ {
52-
include research_centos
37+
node /cryo[-_]em[_-]linux\d+/ {
38+
include cryoem
39+
include pymol_module
5340
}
5441

5542
node foreman {
5643
include centos_server
44+
45+
# backup and replace all configurations monthly
46+
cron { 'cleanfb_monthly':
47+
command => '/usr/bin/yes | /usr/local/bin/cleanfb --name=vai',
48+
user => 'root',
49+
monthday => 1,
50+
}
5751
}
5852

5953
node gongpuvictory {
@@ -62,8 +56,22 @@
6256
include research_centos
6357
}
6458

65-
# matches all of the cryoEM machines
66-
node /cryo[-_]em[_-]linux\d+/ {
67-
include cryoem
68-
include pymol_module
59+
node /^lens\d+$/ {
60+
include research_centos
61+
}
62+
63+
node /matt/ {
64+
include common
65+
include sssd
66+
include graylog
6967
}
68+
69+
70+
node szabo1 {
71+
include common
72+
include graylog
73+
include sssd
74+
include mount_drives
75+
include privileges
76+
}
77+

environments/production/modules/common/lib/facter/adjoin.rb

+10-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
def joined (os)
1616
case os
1717
when "darwin" then return ((`dsconfigad -show | awk '/Active Directory Domain/{print $NF}'`).include? $host)
18-
when "redhat","centos" then return sssd_status
19-
when "windows" then return true
18+
when "redhat","centos", "ubuntu" then return sssd_status
19+
when "windows" then return ((`wmic computersystem get domain`).include? $domain)
2020
else Puppet.notice("Error in AD join. #{os} not currently supported through Puppet.")
2121
end
2222

@@ -37,9 +37,16 @@ def adjoin (os)
3737
case os
3838
when "darwin"
3939
(`dsconfigad -add #{$host} -u #{$ad_admin} -p #{$ad_admin_pass} -domain #{$domain}`)
40-
when "redhat","centos"
40+
when "redhat","centos", "ubuntu"
4141
(`/usr/bin/net ads join -U #{$ad_admin}%#{$ad_admin_pass} createcomputer=LinuxMachines`)
4242
(`/usr/sbin/authconfig --enablesssd --enablesssdauth --enablemkhomedir --updateall`)
43+
when "windows"
44+
return
45+
$user = "$domain\$ad_admin"
46+
$password = (`ConvertTo-SecureString -AsPlainText $ad_admin_pass -Force`)
47+
48+
credential = (`New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user,$password`)
49+
(`Add-Computer -DomainName "$domain" -Credential $credential -Restart -Force`)
4350
end
4451
end
4552

environments/production/modules/common/lib/facter/capture_conf.rb

+19-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Configuration
1616
def initialize
1717
@os = facter_call(:operatingsystem).downcase
1818
@fqdn = facter_call(:fqdn).downcase
19-
19+
2020
@filepath = (@os.include? "windows") ? @@WINDOWS_PATH : @@LINUX_PATH
2121
prefix = "#{@filepath+@fqdn}"
2222
@config_file = prefix + "_configuration.json"
@@ -36,6 +36,7 @@ def run
3636
private
3737

3838
def capture_configuration
39+
3940
puppet_call(:notice, "Capturing current configuration...")
4041

4142
json = []
@@ -61,8 +62,11 @@ def compare_configuration
6162
sum = Digest::MD5.file @config_file
6263
response = filebucket_request(:get, sum: sum)
6364

64-
File.delete(@config_file) if(response.nil? || response.empty?)
65-
65+
if(response.nil? || response.empty?)
66+
File.delete(@config_file)
67+
return
68+
end
69+
6670
saved_configuration = JSON.parse(File.read(@config_file))
6771
current_configuration = JSON.parse(@configuration)
6872

@@ -175,31 +179,37 @@ def puppet_call(type, val)
175179
def restore_configuration
176180
list = filebucket_request(:list)
177181
restored = false
178-
179182
unless(list.nil? || list.empty?)
180183
cached_files = list.split("\n")
181184

185+
counter = 1.0
186+
size = cached_files.size
187+
puppet_call(:notice, "No configuration found at #{@config_file}. ")
188+
puppet_call(:notice, "Searching for cached configuration: ")
189+
182190
cached_files.reverse_each do |line|
183191
next if(!(line.include? @config_file) || restored)
184192

193+
progress = (((counter / size).round(2)) * 100).truncate
194+
puppet_call(:notice, "#{progress}%")
195+
counter += 1
196+
185197
sum = line.split(" ")[0]
186198
response = filebucket_request(:get, sum: sum)
187199

188200
unless(response.nil? || response.empty? || restored)
189201

190202
restored = true
191203
filebucket_request(:restore, file: @config_file, sum: sum)
192-
puppet_call(:notice,
193-
"Restored #{@config_file} from #{@@SERVER} (#{sum})")
194-
204+
puppet_call(:notice, "Restored #{@config_file} from #{@@SERVER} (#{sum})")
195205
end
196206
end
197207
end
198208

199209
if !(restored)
200-
puppet_call(:notice, "No configuration found at #{@config_file}. "\
201-
"Capturing a new configuration.")
202210
save
211+
puppet_call(:notice, "No cached configuration found on server.")
212+
puppet_call(:notice, "Capturing a new configuration...")
203213
end
204214
end
205215

environments/win_test/manifests/site.pp

+18-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,30 @@
22

33
node windev1806eval {
44
include chocolatey
5+
include common
56
package { 'git':
67
ensure => latest,
78
provider => 'chocolatey',
89
}
910

1011
package { 'office365business':
11-
ensure => absent,
12+
ensure => latest,
1213
provider => 'chocolatey',
1314
}
15+
16+
package { 'notepadplusplus':
17+
ensure => latest,
18+
provider => 'chocolatey',
19+
}
20+
21+
package { 'spotify':
22+
ensure => absent,
23+
provider => 'chocolatey',
24+
}
25+
26+
package { 'slack':
27+
ensure => latest,
28+
provider => 'chocolatey',
29+
}
30+
1431
}

0 commit comments

Comments
 (0)