Skip to content

Commit d5975e0

Browse files
authored
Merge pull request #40 from rehanone/develop/streamline-install-inter-dependencies
- Streamline `install` inter-dependencies to ensure all applicable ta…
2 parents 5b93562 + 23dc622 commit d5975e0

File tree

1 file changed

+54
-76
lines changed

1 file changed

+54
-76
lines changed

manifests/install.pp

Lines changed: 54 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,24 @@
6161
$group = $name
6262
}
6363

64+
if $set_sh {
65+
if !defined(User[$name]) {
66+
user { "ohmyzsh::user ${name}":
67+
ensure => present,
68+
name => $name,
69+
managehome => true,
70+
shell => lookup('ohmyzsh::zsh_shell_path'),
71+
require => Package['zsh'],
72+
}
73+
} else {
74+
User <| title == $name |> {
75+
shell => lookup('ohmyzsh::zsh_shell_path')
76+
}
77+
78+
Package['zsh'] -> User <| title == $name |>
79+
}
80+
}
81+
6482
vcsrepo { "${home}/.oh-my-zsh":
6583
ensure => $ensure,
6684
provider => git,
@@ -69,12 +87,12 @@
6987
user => $name,
7088
require => Package['git'],
7189
}
72-
73-
if $update_zshrc == sync {
90+
-> if $update_zshrc == sync {
7491
if $backup_zshrc {
7592
exec { "backup .zshrc ${name}":
7693
command => "cp ${home}/.zshrc ${home}/.zshrc.bak.${date_command}",
7794
path => ['/bin', '/usr/bin'],
95+
onlyif => "test -f ${home}/.zshrc",
7896
user => $name,
7997
before => [
8098
File_Line["ohmyzsh::auto_update_frequency - ${name}"],
@@ -100,118 +118,78 @@
100118
path => ['/bin', '/usr/bin'],
101119
onlyif => "getent passwd ${name} | cut -d : -f 6 | xargs test -e",
102120
user => $name,
103-
require => Vcsrepo["${home}/.oh-my-zsh"],
104-
before => [
105-
File_Line["ohmyzsh::auto_update_frequency - ${name}"],
106-
],
107121
}
108122
} elsif $update_zshrc == always {
109123
if $backup_zshrc {
110124
exec { "backup .zshrc ${name}":
111-
command => "cp ${home}/.zshrc ${home}/.zshrc.bak.${date_command}",
112-
path => ['/bin', '/usr/bin'],
113-
user => $name,
114-
before => [
115-
File_Line["ohmyzsh::auto_update_frequency - ${name}"],
116-
],
117-
require => Vcsrepo["${home}/.oh-my-zsh"],
125+
command => "cp ${home}/.zshrc ${home}/.zshrc.bak.${date_command}",
126+
path => ['/bin', '/usr/bin'],
127+
onlyif => "test -f ${home}/.zshrc",
128+
user => $name,
118129
}
119130
}
120131
-> exec { "ohmyzsh::cp .zshrc ${name}":
121132
command => "cp ${home}/.oh-my-zsh/templates/zshrc.zsh-template ${home}/.zshrc",
122133
path => ['/bin', '/usr/bin'],
123134
user => $name,
124-
before => [
125-
File_Line["ohmyzsh::auto_update_frequency - ${name}"],
126-
],
127-
require => Vcsrepo["${home}/.oh-my-zsh"],
128-
}
129-
}
130-
131-
if $set_sh {
132-
if !defined(User[$name]) {
133-
user { "ohmyzsh::user ${name}":
134-
ensure => present,
135-
name => $name,
136-
managehome => true,
137-
shell => lookup('ohmyzsh::zsh_shell_path'),
138-
require => Package['zsh'],
139-
}
140-
} else {
141-
User <| title == $name |> {
142-
shell => lookup('ohmyzsh::zsh_shell_path')
143-
}
144-
145-
Package['zsh'] -> User <| title == $name |>
146135
}
147136
}
148-
149-
file_line { "ohmyzsh::auto_update_frequency - ${name}":
137+
-> file_line { "ohmyzsh::auto_update_frequency - ${name}":
150138
path => "${home}/.zshrc",
151139
line => "zstyle ':omz:update' frequency ${auto_update_frequency}",
152140
match => '.*zstyle\ \':omz:update\'\ frequency .*',
153141
}
154-
if $auto_update_mode == disabled {
142+
-> if $auto_update_mode == disabled {
155143
file_line { "enable ohmyzsh::auto_update_mode disabled - ${name}":
156-
path => "${home}/.zshrc",
157-
line => "zstyle ':omz:update' mode disabled",
158-
match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*',
159-
require => File_Line["ohmyzsh::auto_update_frequency - ${name}"],
144+
path => "${home}/.zshrc",
145+
line => "zstyle ':omz:update' mode disabled",
146+
match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*',
160147
}
161148
file_line { "disable ohmyzsh::auto_update_mode auto - ${name}":
162-
path => "${home}/.zshrc",
163-
line => "# zstyle ':omz:update' mode auto",
164-
match => '.*zstyle\ \':omz:update\'\ mode\ auto.*',
165-
require => File_Line["ohmyzsh::auto_update_frequency - ${name}"],
149+
path => "${home}/.zshrc",
150+
line => "# zstyle ':omz:update' mode auto",
151+
match => '.*zstyle\ \':omz:update\'\ mode\ auto.*',
166152
}
167153
file_line { "disable ohmyzsh::auto_update_mode reminder - ${name}":
168-
path => "${home}/.zshrc",
169-
line => "# zstyle ':omz:update' mode reminder",
170-
match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*',
171-
require => File_Line["ohmyzsh::auto_update_frequency - ${name}"],
154+
path => "${home}/.zshrc",
155+
line => "# zstyle ':omz:update' mode reminder",
156+
match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*',
172157
}
173158
} elsif $auto_update_mode == auto {
174159
file_line { "enable ohmyzsh::auto_update_mode auto - ${name}":
175-
path => "${home}/.zshrc",
176-
line => "zstyle ':omz:update' mode auto",
177-
match => '.*zstyle\ \':omz:update\'\ mode\ auto.*',
178-
require => File_Line["ohmyzsh::auto_update_frequency - ${name}"],
160+
path => "${home}/.zshrc",
161+
line => "zstyle ':omz:update' mode auto",
162+
match => '.*zstyle\ \':omz:update\'\ mode\ auto.*',
179163
}
180164
file_line { "disable ohmyzsh::auto_update_mode disabled - ${name}":
181-
path => "${home}/.zshrc",
182-
line => "# zstyle ':omz:update' mode disabled",
183-
match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*',
184-
require => File_Line["ohmyzsh::auto_update_frequency - ${name}"],
165+
path => "${home}/.zshrc",
166+
line => "# zstyle ':omz:update' mode disabled",
167+
match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*',
185168
}
186169
file_line { "disable ohmyzsh::auto_update_mode reminder - ${name}":
187-
path => "${home}/.zshrc",
188-
line => "# zstyle ':omz:update' mode reminder",
189-
match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*',
190-
require => File_Line["ohmyzsh::auto_update_frequency - ${name}"],
170+
path => "${home}/.zshrc",
171+
line => "# zstyle ':omz:update' mode reminder",
172+
match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*',
191173
}
192174
} elsif $auto_update_mode == reminder {
193175
file_line { "enable ohmyzsh::auto_update_mode reminder - ${name}":
194-
path => "${home}/.zshrc",
195-
line => "zstyle ':omz:update' mode reminder",
196-
match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*',
197-
require => File_Line["ohmyzsh::auto_update_frequency - ${name}"],
176+
path => "${home}/.zshrc",
177+
line => "zstyle ':omz:update' mode reminder",
178+
match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*',
198179
}
199180
file_line { "disable ohmyzsh::auto_update_mode auto - ${name}":
200-
path => "${home}/.zshrc",
201-
line => "# zstyle ':omz:update' mode auto",
202-
match => '.*zstyle\ \':omz:update\'\ mode\ auto.*',
203-
require => File_Line["ohmyzsh::auto_update_frequency - ${name}"],
181+
path => "${home}/.zshrc",
182+
line => "# zstyle ':omz:update' mode auto",
183+
match => '.*zstyle\ \':omz:update\'\ mode\ auto.*',
204184
}
205185
file_line { "disable ohmyzsh::auto_update_mode disabled - ${name}":
206-
path => "${home}/.zshrc",
207-
line => "# zstyle ':omz:update' mode disabled",
208-
match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*',
209-
require => File_Line["ohmyzsh::auto_update_frequency - ${name}"],
186+
path => "${home}/.zshrc",
187+
line => "# zstyle ':omz:update' mode disabled",
188+
match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*',
210189
}
211190
}
212-
213191
# Fix permissions on '~/.oh-my-zsh/cache/completions'
214-
file { "${home}/.oh-my-zsh/cache/completions":
192+
-> file { "${home}/.oh-my-zsh/cache/completions":
215193
ensure => directory,
216194
replace => 'no',
217195
owner => $name,

0 commit comments

Comments
 (0)