diff --git a/.fixtures.yml b/.fixtures.yml
index e6e58f6..3e752a2 100644
--- a/.fixtures.yml
+++ b/.fixtures.yml
@@ -4,6 +4,7 @@ fixtures:
repo: "puppetlabs/stdlib"
vcsrepo:
repo: "puppetlabs/vcsrepo"
+ ref: "5.5.0"
repositories:
wget: "https://github.com/rehanone/puppet-wget.git"
symlinks:
diff --git a/REFERENCE.md b/REFERENCE.md
new file mode 100644
index 0000000..a3c27ac
--- /dev/null
+++ b/REFERENCE.md
@@ -0,0 +1,299 @@
+# Reference
+
+
+
+## Table of Contents
+
+### Classes
+
+* [`ohmyzsh`](#ohmyzsh): Install and configure Oh-My-ZSH
+
+### Defined types
+
+#### Public Defined types
+
+* [`ohmyzsh::fetch::theme`](#ohmyzshfetchtheme): Install a theme from a defined source
+* [`ohmyzsh::install`](#ohmyzshinstall): Install and configure Oh-My-ZSH for an user
+* [`ohmyzsh::plugins`](#ohmyzshplugins): Install and configure Oh-My-ZSH plugins for an user
+* [`ohmyzsh::profile`](#ohmyzshprofile): Configure the ZSH profile for an user
+* [`ohmyzsh::theme`](#ohmyzshtheme): Configure the ZSH theme for an user
+
+#### Private Defined types
+
+* `ohmyzsh::install::classic`: Manage the zsh file with the original mode (file copy from the repository)
+* `ohmyzsh::install::concat`: Manage the zsh file with concat
+
+## Classes
+
+### `ohmyzsh`
+
+This is the ohmyzsh module. It creates a profile directory under user home and allows
+custom scripts to setup and made avalible on the path.
+
+This module is called ohmyzsh as Puppet does not support hyphens in module
+names.
+
+View README.md for full documentation.
+
+#### Parameters
+
+The following parameters are available in the `ohmyzsh` class:
+
+* [`source`](#source)
+* [`home`](#home)
+* [`zsh_shell_path`](#zsh_shell_path)
+* [`installs`](#installs)
+* [`themes`](#themes)
+* [`plugins`](#plugins)
+* [`profiles`](#profiles)
+* [`concat`](#concat)
+
+##### `source`
+
+Data type: `Stdlib::Httpsurl`
+
+Oh-My-ZSH repository. See data/ for the default value.
+
+##### `home`
+
+Data type: `Stdlib::Absolutepath`
+
+Default home base directory. See data/ for the default value.
+
+##### `zsh_shell_path`
+
+Data type: `Stdlib::Absolutepath`
+
+Path of the zsh executable. See data/ for the default value.
+
+##### `installs`
+
+Data type: `Hash`
+
+Install and configure Oh-My-ZSH for users defined in this hash. See data/ for the default value.
+
+##### `themes`
+
+Data type: `Hash`
+
+Configure the themes for users defined in this hash. See data/ for the default value.
+
+##### `plugins`
+
+Data type: `Hash`
+
+Configure the plugins for users defined in this hash. See data/ for the default value.
+
+##### `profiles`
+
+Data type: `Hash`
+
+Configure the profile for users defined in this hash. See data/ for the default value.
+
+##### `concat`
+
+Data type: `Boolean`
+
+Use the concat module to manage .zshrc files.
+
+## Defined types
+
+### `ohmyzsh::fetch::theme`
+
+Install a theme from a defined source
+
+#### Parameters
+
+The following parameters are available in the `ohmyzsh::fetch::theme` defined type:
+
+* [`url`](#url)
+* [`source`](#source)
+* [`content`](#content)
+* [`filename`](#filename)
+* [`revision`](#revision)
+* [`depth`](#depth)
+
+##### `url`
+
+Data type: `Optional[Stdlib::Httpurl]`
+
+The URL of the git repository (if `source` is `git`) or to the file
+
+Default value: ``undef``
+
+##### `source`
+
+Data type: `Optional[String]`
+
+`git` for a repository, `undef` for a file to download or the source to pass to Puppet `file`
+
+Default value: ``undef``
+
+##### `content`
+
+Data type: `Optional[String]`
+
+The content to pass to Puppet `file`, only if `source` and `url` is unset.
+
+Default value: ``undef``
+
+##### `filename`
+
+Data type: `Optional[String]`
+
+The file name to use while saving the theme
+
+Default value: ``undef``
+
+##### `revision`
+
+Data type: `Optional[String]`
+
+Revision to checkout while using Git
+
+Default value: ``undef``
+
+##### `depth`
+
+Data type: `Optional[Integer]`
+
+Controls the shallow clone for Git
+
+Default value: ``undef``
+
+### `ohmyzsh::install`
+
+Install and configure Oh-My-ZSH for an user
+
+#### Parameters
+
+The following parameters are available in the `ohmyzsh::install` defined type:
+
+* [`ensure`](#ensure)
+* [`set_sh`](#set_sh)
+* [`update_zshrc`](#update_zshrc)
+* [`backup_zshrc`](#backup_zshrc)
+* [`auto_update_mode`](#auto_update_mode)
+* [`auto_update_frequency`](#auto_update_frequency)
+
+##### `ensure`
+
+Data type: `Enum[present, latest]`
+
+Controls the way the Oh-My-ZSH repository is managed by Puppet.
+
+Default value: `latest`
+
+##### `set_sh`
+
+Data type: `Boolean`
+
+Controls whether to change the user shell to zsh.
+
+Default value: ``false``
+
+##### `update_zshrc`
+
+Data type: `Enum[always, disabled, sync]`
+
+Controls the update of .zshrc from the upstream template.
+
+Default value: `disabled`
+
+##### `backup_zshrc`
+
+Data type: `Boolean`
+
+Controls if a backup of .zshrc need to be sone before changes.
+
+Default value: ``true``
+
+##### `auto_update_mode`
+
+Data type: `Enum[auto, disabled, reminder]`
+
+Controls the update check for oh-my-zsh.
+
+Default value: `disabled`
+
+##### `auto_update_frequency`
+
+Data type: `Integer[0]`
+
+Controls the update check frequency.
+
+Default value: `14`
+
+### `ohmyzsh::plugins`
+
+Install and configure Oh-My-ZSH plugins for an user
+
+#### Parameters
+
+The following parameters are available in the `ohmyzsh::plugins` defined type:
+
+* [`plugins`](#plugins)
+* [`custom_plugins`](#custom_plugins)
+
+##### `plugins`
+
+Data type: `Array[String]`
+
+List of built-in plugins.
+
+Default value: `['git']`
+
+##### `custom_plugins`
+
+Data type: `Hash[String,
+ Struct[
+ {
+ source => Enum[git],
+ url => Stdlib::Httpsurl,
+ ensure => Enum[present, latest],
+ revision => Optional[String],
+ depth => Optional[Integer]
+ }
+ ]
+ ]`
+
+List of plugins to install and use.
+
+Default value: `{}`
+
+### `ohmyzsh::profile`
+
+Configure the ZSH profile for an user
+
+#### Parameters
+
+The following parameters are available in the `ohmyzsh::profile` defined type:
+
+* [`scripts`](#scripts)
+
+##### `scripts`
+
+Data type: `Hash[String[1], Stdlib::Filesource]`
+
+A hash of name => paths to all the scripts.
+
+Default value: `{}`
+
+### `ohmyzsh::theme`
+
+Configure the ZSH theme for an user
+
+#### Parameters
+
+The following parameters are available in the `ohmyzsh::theme` defined type:
+
+* [`theme`](#theme)
+
+##### `theme`
+
+Data type: `String`
+
+The name of the theme to use.
+
+Default value: `'clean'`
+
diff --git a/data/common.yaml b/data/common.yaml
index 3e89eb6..a7bf402 100644
--- a/data/common.yaml
+++ b/data/common.yaml
@@ -7,3 +7,4 @@ ohmyzsh::installs: {}
ohmyzsh::themes: {}
ohmyzsh::plugins: {}
ohmyzsh::profiles: {}
+ohmyzsh::concat: false
diff --git a/examples/concat-with-local-overrides.pp b/examples/concat-with-local-overrides.pp
new file mode 100644
index 0000000..0a73057
--- /dev/null
+++ b/examples/concat-with-local-overrides.pp
@@ -0,0 +1,38 @@
+class { 'ohmyzsh':
+ concat => true,
+}
+
+# for a single user
+ohmyzsh::install { 'root':
+ set_sh => true,
+ auto_update_mode => reminder,
+ auto_update_frequency => 7,
+}
+
+file { '/root/.zshrc.local':
+ ensure => file,
+ replace => 'no',
+ owner => 'root',
+ group => 'root',
+ mode => '0644',
+ content => "# Use this file to customize ZSH, it's not managed by Puppet",
+}
+
+concat::fragment { '/root/.zshrc:puppet':
+ target => '/root/.zshrc',
+ content => "### Use the file ~/.zshrc.local for your changes\n",
+ order => '000',
+}
+
+concat::fragment { '/root/.zshrc:load-local':
+ target => '/root/.zshrc',
+ content => @("EOF"/L)
+ # Load local zshrc if exist
+ if [ -f ~/.zshrc.local ]
+ then
+ source ~/.zshrc.local
+ fi
+ | EOF
+ ,
+ order => '099',
+}
diff --git a/examples/concat-with-powerlevel10k.pp b/examples/concat-with-powerlevel10k.pp
new file mode 100644
index 0000000..1c0abb4
--- /dev/null
+++ b/examples/concat-with-powerlevel10k.pp
@@ -0,0 +1,43 @@
+class { 'ohmyzsh':
+ concat => true,
+}
+
+# for a single user
+ohmyzsh::install { 'root':
+ set_sh => true,
+ auto_update_mode => reminder,
+ auto_update_frequency => 7,
+}
+
+ohmyzsh::fetch::theme { 'root':
+ filename => 'powerlevel10k',
+ source => 'git',
+ depth => 1,
+ url => 'https://github.com/romkatv/powerlevel10k.git',
+}
+
+ohmyzsh::theme { 'root':
+ theme => 'powerlevel10k/powerlevel10k',
+}
+
+ohmyzsh::plugins { 'root':
+ plugins => ['git', 'github'],
+}
+
+file { '/root/.p10k.zsh':
+ owner => 'root',
+ group => 'root',
+ content => 'YOUR P10K CONFIGURATION FILE',
+}
+
+concat::fragment { '/root/.zshrc:p10k-instant-prompt':
+ target => '/root/.zshrc',
+ content => 'YOUR P10K INSTANT PROMPT SNIPPET',
+ order => '005',
+}
+
+concat::fragment { '/root/.zshrc:p10k-load':
+ target => '/root/.zshrc',
+ content => "[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh\n",
+ order => '095',
+}
diff --git a/files/concat/zshrc-000-header.zsh-template b/files/concat/zshrc-000-header.zsh-template
new file mode 100644
index 0000000..c5d132c
--- /dev/null
+++ b/files/concat/zshrc-000-header.zsh-template
@@ -0,0 +1 @@
+### This file is managed by Puppet, any changes will be lost
diff --git a/files/concat/zshrc-010-export.zsh-template b/files/concat/zshrc-010-export.zsh-template
new file mode 100644
index 0000000..1bfd879
--- /dev/null
+++ b/files/concat/zshrc-010-export.zsh-template
@@ -0,0 +1,3 @@
+### Puppet Concat: zshrc-010-export.zsh-template
+# Path to your oh-my-zsh installation.
+export ZSH=$HOME/.oh-my-zsh
diff --git a/files/concat/zshrc-070-source.zsh-template b/files/concat/zshrc-070-source.zsh-template
new file mode 100644
index 0000000..fce6641
--- /dev/null
+++ b/files/concat/zshrc-070-source.zsh-template
@@ -0,0 +1,2 @@
+### Puppet Concat: zshrc-070-source.zsh-template
+source $ZSH/oh-my-zsh.sh
diff --git a/manifests/fetch/theme.pp b/manifests/fetch/theme.pp
index a525e53..e6f4b18 100644
--- a/manifests/fetch/theme.pp
+++ b/manifests/fetch/theme.pp
@@ -1,3 +1,19 @@
+#
+# @summary Install a theme from a defined source
+#
+#
+# @param url The URL of the git repository (if `source` is `git`) or to the file
+# @param source `git` for a repository, `undef` for a file to download or the source to pass to Puppet `file`
+# @param content The content to pass to Puppet `file`, only if `source` and `url` is unset.
+# @param filename The file name to use while saving the theme
+# @param revision Revision to checkout while using Git
+# @param depth Controls the shallow clone for Git
+#
+#
+# @author Leon Brocard
+# @author Zan Loy
+# @author Rehan Mahmood
+#
define ohmyzsh::fetch::theme (
Optional[Stdlib::Httpurl] $url = undef,
Optional[String] $source = undef,
diff --git a/manifests/init.pp b/manifests/init.pp
index a305ad9..f49d543 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -1,14 +1,28 @@
+#
+# @summary Install and configure Oh-My-ZSH
+#
+# This is the ohmyzsh module. It creates a profile directory under user home and allows
+# custom scripts to setup and made avalible on the path.
+#
+# This module is called ohmyzsh as Puppet does not support hyphens in module
+# names.
+#
# View README.md for full documentation.
#
-# === Authors
#
-# Leon Brocard
-# Zan Loy
-# Rehan Mahmood
+# @param source Oh-My-ZSH repository. See data/ for the default value.
+# @param home Default home base directory. See data/ for the default value.
+# @param zsh_shell_path Path of the zsh executable. See data/ for the default value.
+# @param installs Install and configure Oh-My-ZSH for users defined in this hash. See data/ for the default value.
+# @param themes Configure the themes for users defined in this hash. See data/ for the default value.
+# @param plugins Configure the plugins for users defined in this hash. See data/ for the default value.
+# @param profiles Configure the profile for users defined in this hash. See data/ for the default value.
+# @param concat Use the concat module to manage .zshrc files.
#
-# === Copyright
#
-# Copyright 2019
+# @author Leon Brocard
+# @author Zan Loy
+# @author Rehan Mahmood
#
class ohmyzsh (
Stdlib::Httpsurl $source,
@@ -18,6 +32,7 @@
Hash $themes,
Hash $plugins,
Hash $profiles,
+ Boolean $concat,
) {
create_resources('ohmyzsh::install', $ohmyzsh::installs)
create_resources('ohmyzsh::theme', $ohmyzsh::themes)
diff --git a/manifests/install.pp b/manifests/install.pp
index 18ec4cc..83a2d8c 100644
--- a/manifests/install.pp
+++ b/manifests/install.pp
@@ -1,29 +1,18 @@
-# == Define: ohmyzsh::install
#
-# This is the ohmyzsh module. It installs oh-my-zsh for a user and changes
-# their shell to zsh. It has been tested under Ubuntu.
+# @summary Install and configure Oh-My-ZSH for an user
#
-# This module is called ohmyzsh as Puppet does not support hyphens in module
-# names.
#
-# oh-my-zsh is a community-driven framework for managing your zsh configuration.
+# @param ensure Controls the way the Oh-My-ZSH repository is managed by Puppet.
+# @param set_sh Controls whether to change the user shell to zsh.
+# @param update_zshrc Controls the update of .zshrc from the upstream template.
+# @param backup_zshrc Controls if a backup of .zshrc need to be sone before changes.
+# @param auto_update_mode Controls the update check for oh-my-zsh.
+# @param auto_update_frequency Controls the update check frequency.
#
-# === Parameters
#
-# set_sh: (boolean) controls whether to change the user shell to zsh
-# update_zshrc: (enum) controls the update of .zshrc from the upstream template. Default value is `disabled`
-# auto_update_mode: (enum) controls the update check for oh-my-zsh. Default value is `disabled`.
-# auto_update_frequency: (integer) controls the update check frequency. Default value is `14`.
-#
-# === Authors
-#
-# Leon Brocard
-# Zan Loy
-# Rehan Mahmood
-#
-# === Copyright
-#
-# Copyright 2022
+# @author Leon Brocard
+# @author Zan Loy
+# @author Rehan Mahmood
#
define ohmyzsh::install (
Enum[present, latest] $ensure = latest,
@@ -36,7 +25,6 @@
Integer[0] $auto_update_frequency = 14,
) {
include ohmyzsh
- $date_command = '$(date +\'%Y-%m-%dT%H:%M:%S%:z\')'
if !defined(Package['git']) {
package { 'git':
@@ -87,105 +75,21 @@
user => $name,
require => Package['git'],
}
- -> if $update_zshrc == sync {
- if $backup_zshrc {
- exec { "backup .zshrc ${name}":
- command => "cp ${home}/.zshrc ${home}/.zshrc.bak.${date_command}",
- path => ['/bin', '/usr/bin'],
- onlyif => "test -f ${home}/.zshrc",
- user => $name,
- before => [
- File_Line["ohmyzsh::auto_update_frequency - ${name}"],
- ],
- subscribe => Vcsrepo["${home}/.oh-my-zsh"],
- refreshonly => true,
- }
- }
- -> exec { "ohmyzsh::cp .zshrc ${name}":
- command => "cp ${home}/.oh-my-zsh/templates/zshrc.zsh-template ${home}/.zshrc",
- path => ['/bin', '/usr/bin'],
- user => $name,
- before => [
- File_Line["ohmyzsh::auto_update_frequency - ${name}"],
- ],
- subscribe => Vcsrepo["${home}/.oh-my-zsh"],
- refreshonly => true,
+ -> unless $ohmyzsh::concat {
+ ohmyzsh::install::classic { $name:
+ update_zshrc => $update_zshrc,
+ backup_zshrc => $backup_zshrc,
+ auto_update_mode => $auto_update_mode,
+ auto_update_frequency => $auto_update_frequency,
+ home => $home,
+ group => $group,
}
- } elsif $update_zshrc == disabled {
- exec { "ohmyzsh::cp .zshrc ${name}":
- creates => "${home}/.zshrc",
- command => "cp ${home}/.oh-my-zsh/templates/zshrc.zsh-template ${home}/.zshrc",
- path => ['/bin', '/usr/bin'],
- onlyif => "getent passwd ${name} | cut -d : -f 6 | xargs test -e",
- user => $name,
- }
- } elsif $update_zshrc == always {
- if $backup_zshrc {
- exec { "backup .zshrc ${name}":
- command => "cp ${home}/.zshrc ${home}/.zshrc.bak.${date_command}",
- path => ['/bin', '/usr/bin'],
- onlyif => "test -f ${home}/.zshrc",
- user => $name,
- }
- }
- -> exec { "ohmyzsh::cp .zshrc ${name}":
- command => "cp ${home}/.oh-my-zsh/templates/zshrc.zsh-template ${home}/.zshrc",
- path => ['/bin', '/usr/bin'],
- user => $name,
- }
- }
- -> file_line { "ohmyzsh::auto_update_frequency - ${name}":
- path => "${home}/.zshrc",
- line => "zstyle ':omz:update' frequency ${auto_update_frequency}",
- match => '.*zstyle\ \':omz:update\'\ frequency .*',
- }
- -> if $auto_update_mode == disabled {
- file_line { "enable ohmyzsh::auto_update_mode disabled - ${name}":
- path => "${home}/.zshrc",
- line => "zstyle ':omz:update' mode disabled",
- match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*',
- }
- file_line { "disable ohmyzsh::auto_update_mode auto - ${name}":
- path => "${home}/.zshrc",
- line => "# zstyle ':omz:update' mode auto",
- match => '.*zstyle\ \':omz:update\'\ mode\ auto.*',
- }
- file_line { "disable ohmyzsh::auto_update_mode reminder - ${name}":
- path => "${home}/.zshrc",
- line => "# zstyle ':omz:update' mode reminder",
- match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*',
- }
- } elsif $auto_update_mode == auto {
- file_line { "enable ohmyzsh::auto_update_mode auto - ${name}":
- path => "${home}/.zshrc",
- line => "zstyle ':omz:update' mode auto",
- match => '.*zstyle\ \':omz:update\'\ mode\ auto.*',
- }
- file_line { "disable ohmyzsh::auto_update_mode disabled - ${name}":
- path => "${home}/.zshrc",
- line => "# zstyle ':omz:update' mode disabled",
- match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*',
- }
- file_line { "disable ohmyzsh::auto_update_mode reminder - ${name}":
- path => "${home}/.zshrc",
- line => "# zstyle ':omz:update' mode reminder",
- match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*',
- }
- } elsif $auto_update_mode == reminder {
- file_line { "enable ohmyzsh::auto_update_mode reminder - ${name}":
- path => "${home}/.zshrc",
- line => "zstyle ':omz:update' mode reminder",
- match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*',
- }
- file_line { "disable ohmyzsh::auto_update_mode auto - ${name}":
- path => "${home}/.zshrc",
- line => "# zstyle ':omz:update' mode auto",
- match => '.*zstyle\ \':omz:update\'\ mode\ auto.*',
- }
- file_line { "disable ohmyzsh::auto_update_mode disabled - ${name}":
- path => "${home}/.zshrc",
- line => "# zstyle ':omz:update' mode disabled",
- match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*',
+ } else {
+ ohmyzsh::install::concat { $name:
+ auto_update_mode => $auto_update_mode,
+ auto_update_frequency => $auto_update_frequency,
+ home => $home,
+ group => $group,
}
}
# Fix permissions on '~/.oh-my-zsh/cache/completions'
diff --git a/manifests/install/classic.pp b/manifests/install/classic.pp
new file mode 100644
index 0000000..ed251e2
--- /dev/null
+++ b/manifests/install/classic.pp
@@ -0,0 +1,131 @@
+#
+# @api private
+#
+#
+# @summary Manage the zsh file with the original mode (file copy from the repository)
+#
+#
+# @param update_zshrc Controls the update of .zshrc from the upstream template.
+# @param auto_update_mode Controls the update check for oh-my-zsh.
+# @param auto_update_frequency Controls the update check frequency.
+# @param home Controls the home directory of the install
+# @param group Controls the group of the files
+#
+#
+# @author Leon Brocard
+# @author Zan Loy
+# @author Rehan Mahmood
+#
+define ohmyzsh::install::classic (
+ Enum[always, disabled, sync] $update_zshrc,
+ Boolean $backup_zshrc,
+ Enum[auto, disabled, reminder] $auto_update_mode,
+ Integer[0] $auto_update_frequency,
+ String $home,
+ String $group,
+) {
+ assert_private()
+ $date_command = '$(date +\'%Y-%m-%dT%H:%M:%S%:z\')'
+
+ if $update_zshrc == sync {
+ if $backup_zshrc {
+ exec { "backup .zshrc ${name}":
+ command => "cp ${home}/.zshrc ${home}/.zshrc.bak.${date_command}",
+ path => ['/bin', '/usr/bin'],
+ onlyif => "test -f ${home}/.zshrc",
+ user => $name,
+ before => [
+ File_Line["ohmyzsh::auto_update_frequency - ${name}"],
+ ],
+ subscribe => Vcsrepo["${home}/.oh-my-zsh"],
+ refreshonly => true,
+ }
+ }
+ -> exec { "ohmyzsh::cp .zshrc ${name}":
+ command => "cp ${home}/.oh-my-zsh/templates/zshrc.zsh-template ${home}/.zshrc",
+ path => ['/bin', '/usr/bin'],
+ user => $name,
+ before => [
+ File_Line["ohmyzsh::auto_update_frequency - ${name}"],
+ ],
+ subscribe => Vcsrepo["${home}/.oh-my-zsh"],
+ refreshonly => true,
+ }
+ } elsif $update_zshrc == disabled {
+ exec { "ohmyzsh::cp .zshrc ${name}":
+ creates => "${home}/.zshrc",
+ command => "cp ${home}/.oh-my-zsh/templates/zshrc.zsh-template ${home}/.zshrc",
+ path => ['/bin', '/usr/bin'],
+ onlyif => "getent passwd ${name} | cut -d : -f 6 | xargs test -e",
+ user => $name,
+ }
+ } elsif $update_zshrc == always {
+ if $backup_zshrc {
+ exec { "backup .zshrc ${name}":
+ command => "cp ${home}/.zshrc ${home}/.zshrc.bak.${date_command}",
+ path => ['/bin', '/usr/bin'],
+ onlyif => "test -f ${home}/.zshrc",
+ user => $name,
+ }
+ }
+ -> exec { "ohmyzsh::cp .zshrc ${name}":
+ command => "cp ${home}/.oh-my-zsh/templates/zshrc.zsh-template ${home}/.zshrc",
+ path => ['/bin', '/usr/bin'],
+ user => $name,
+ }
+ }
+ -> file_line { "ohmyzsh::auto_update_frequency - ${name}":
+ path => "${home}/.zshrc",
+ line => "zstyle ':omz:update' frequency ${auto_update_frequency}",
+ match => '.*zstyle\ \':omz:update\'\ frequency .*',
+ }
+ -> if $auto_update_mode == disabled {
+ file_line { "enable ohmyzsh::auto_update_mode disabled - ${name}":
+ path => "${home}/.zshrc",
+ line => "zstyle ':omz:update' mode disabled",
+ match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*',
+ }
+ file_line { "disable ohmyzsh::auto_update_mode auto - ${name}":
+ path => "${home}/.zshrc",
+ line => "# zstyle ':omz:update' mode auto",
+ match => '.*zstyle\ \':omz:update\'\ mode\ auto.*',
+ }
+ file_line { "disable ohmyzsh::auto_update_mode reminder - ${name}":
+ path => "${home}/.zshrc",
+ line => "# zstyle ':omz:update' mode reminder",
+ match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*',
+ }
+ } elsif $auto_update_mode == auto {
+ file_line { "enable ohmyzsh::auto_update_mode auto - ${name}":
+ path => "${home}/.zshrc",
+ line => "zstyle ':omz:update' mode auto",
+ match => '.*zstyle\ \':omz:update\'\ mode\ auto.*',
+ }
+ file_line { "disable ohmyzsh::auto_update_mode disabled - ${name}":
+ path => "${home}/.zshrc",
+ line => "# zstyle ':omz:update' mode disabled",
+ match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*',
+ }
+ file_line { "disable ohmyzsh::auto_update_mode reminder - ${name}":
+ path => "${home}/.zshrc",
+ line => "# zstyle ':omz:update' mode reminder",
+ match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*',
+ }
+ } elsif $auto_update_mode == reminder {
+ file_line { "enable ohmyzsh::auto_update_mode reminder - ${name}":
+ path => "${home}/.zshrc",
+ line => "zstyle ':omz:update' mode reminder",
+ match => '.*zstyle\ \':omz:update\'\ mode\ reminder.*',
+ }
+ file_line { "disable ohmyzsh::auto_update_mode auto - ${name}":
+ path => "${home}/.zshrc",
+ line => "# zstyle ':omz:update' mode auto",
+ match => '.*zstyle\ \':omz:update\'\ mode\ auto.*',
+ }
+ file_line { "disable ohmyzsh::auto_update_mode disabled - ${name}":
+ path => "${home}/.zshrc",
+ line => "# zstyle ':omz:update' mode disabled",
+ match => '.*zstyle\ \':omz:update\'\ mode\ disabled.*',
+ }
+ }
+}
diff --git a/manifests/install/concat.pp b/manifests/install/concat.pp
new file mode 100644
index 0000000..f3853ac
--- /dev/null
+++ b/manifests/install/concat.pp
@@ -0,0 +1,58 @@
+#
+# @api private
+#
+#
+# @summary Manage the zsh file with concat
+#
+#
+# @param auto_update_mode Controls the update check for oh-my-zsh.
+# @param auto_update_frequency Controls the update check frequency.
+# @param home Controls the home directory of the install
+# @param group Controls the group of the files
+#
+#
+# @author David Cachau
+#
+define ohmyzsh::install::concat (
+ Enum[auto, disabled, reminder] $auto_update_mode,
+ Integer[0] $auto_update_frequency,
+ String $home,
+ String $group,
+) {
+ assert_private()
+
+ concat { "${home}/.zshrc":
+ ensure => present,
+ owner => $name,
+ group => $group,
+ mode => '0644',
+ require => Vcsrepo["${home}/.oh-my-zsh"],
+ }
+
+ concat::fragment { "${home}/.zshrc:000-header":
+ target => "${home}/.zshrc",
+ source => "puppet:///modules/${module_name}/concat/zshrc-000-header.zsh-template",
+ order => '000',
+ }
+
+ concat::fragment { "${home}/.zshrc:010-export":
+ target => "${home}/.zshrc",
+ source => "puppet:///modules/${module_name}/concat/zshrc-010-export.zsh-template",
+ order => '010',
+ }
+
+ concat::fragment { "${home}/.zshrc:050-update":
+ target => "${home}/.zshrc",
+ content => epp("${module_name}/concat/zshrc-050-update.zsh-template.epp", {
+ auto_update_mode => $auto_update_mode,
+ auto_update_frequency => $auto_update_frequency,
+ }),
+ order => '050',
+ }
+
+ concat::fragment { "${home}/.zshrc:070-source":
+ target => "${home}/.zshrc",
+ source => "puppet:///modules/${module_name}/concat/zshrc-070-source.zsh-template",
+ order => '070',
+ }
+}
diff --git a/manifests/plugins.pp b/manifests/plugins.pp
index 20d9d8a..8cb3b4b 100644
--- a/manifests/plugins.pp
+++ b/manifests/plugins.pp
@@ -1,25 +1,13 @@
-# == Define: ohmyzsh::plugins
#
-# This is the ohmyzsh module. It installs oh-my-zsh for a user and changes
-# their shell to zsh. It has been tested under Ubuntu.
+# @summary Install and configure Oh-My-ZSH plugins for an user
#
-# This module is called ohmyzsh as Puppet does not support hyphens in module
-# names.
#
-# oh-my-zsh is a community-driven framework for managing your zsh configuration.
+# @param plugins List of built-in plugins.
+# @param custom_plugins List of plugins to install and use.
#
-# === Parameters
#
-# plugins: (string) space separated list of tmux plugins
-#
-# === Authors
-#
-# Leon Brocard
-# Zan Loy
-#
-# === Copyright
-#
-# Copyright 2014
+# @author Leon Brocard
+# @author Zan Loy
#
define ohmyzsh::plugins (
Array[String] $plugins = ['git'],
@@ -65,10 +53,19 @@
$plugins_real = join($all_plugins, ' ')
- file_line { "${name}-${plugins_real}-install":
- path => "${home}/.zshrc",
- line => "plugins=(${plugins_real})",
- match => '^plugins=',
- require => Ohmyzsh::Install[$name],
+ unless $ohmyzsh::concat {
+ file_line { "${name}-${plugins_real}-install":
+ path => "${home}/.zshrc",
+ line => "plugins=(${plugins_real})",
+ match => '^plugins=',
+ require => Ohmyzsh::Install[$name],
+ }
+ } else {
+ concat::fragment { "${home}/.zshrc:plugins":
+ target => "${home}/.zshrc",
+ content => "plugins=(${plugins_real})\n",
+ order => '060',
+ require => Ohmyzsh::Install[$name],
+ }
}
}
diff --git a/manifests/profile.pp b/manifests/profile.pp
index 7d973a0..4ca1902 100644
--- a/manifests/profile.pp
+++ b/manifests/profile.pp
@@ -1,19 +1,11 @@
-# == Define: ohmyzsh::profile
#
-# This is the ohmyzsh module. It creates a profile directory under user home and allows
-# custom scripts to setup and made avalible on the path.
+# @summary Configure the ZSH profile for an user
#
-# This module is called ohmyzsh as Puppet does not support hyphens in module
-# names.
#
-# oh-my-zsh is a community-driven framework for managing your zsh configuration.
-#
-# === Parameters
-#
-# scripts: (array) An array of paths to all the scripts
+# @param scripts A hash of name => paths to all the scripts.
#
define ohmyzsh::profile (
- Hash $scripts = {},
+ Hash[String[1], Stdlib::Filesource] $scripts = {},
) {
include ohmyzsh
@@ -36,15 +28,25 @@
owner => $name,
require => User[$name],
}
- -> file_line { "${home}-profile":
- ensure => present,
- line => 'for f in ~/profile/*; do source "$f"; done',
- match => 'for f in ~/profile/*; do source "$f"; done',
- path => $shell_resource_path,
- require => [
- User[$name],
- Ohmyzsh::Install[$name],
- ],
+
+ unless $ohmyzsh::concat {
+ file_line { "${home}-profile":
+ ensure => present,
+ line => 'for f in ~/profile/*; do source "$f"; done',
+ match => 'for f in ~/profile/*; do source "$f"; done',
+ path => $shell_resource_path,
+ require => [
+ User[$name],
+ Ohmyzsh::Install[$name],
+ ],
+ }
+ } else {
+ concat::fragment { "${home}/.zshrc:profile":
+ target => "${home}/.zshrc",
+ content => "for f in ~/profile/*; do source \"\$f\"; done\n",
+ order => '080',
+ require => Ohmyzsh::Install[$name],
+ }
}
$scripts.each |$script_name, $script_path| {
diff --git a/manifests/theme.pp b/manifests/theme.pp
index 77c7979..152b16d 100644
--- a/manifests/theme.pp
+++ b/manifests/theme.pp
@@ -1,25 +1,12 @@
-# == Define: ohmyzsh::theme
#
-# This is the ohmyzsh module. It installs oh-my-zsh for a user and changes
-# their shell to zsh. It has been tested under Ubuntu.
+# @summary Configure the ZSH theme for an user
#
-# This module is called ohmyzsh as Puppet does not support hyphens in module
-# names.
#
-# oh-my-zsh is a community-driven framework for managing your zsh configuration.
+# @param theme The name of the theme to use.
#
-# === Parameters
#
-# set_sh: (boolean) whether to change the user shell to zsh
-#
-# === Authors
-#
-# Leon Brocard
-# Zan Loy
-#
-# === Copyright
-#
-# Copyright 2014
+# @author Leon Brocard
+# @author Zan Loy
#
define ohmyzsh::theme (
String $theme = 'clean',
@@ -37,10 +24,19 @@
$group = $name
}
- file_line { "${name}-${theme}-install":
- path => "${home}/.zshrc",
- line => "ZSH_THEME=\"${theme}\"",
- match => '^ZSH_THEME',
- require => Ohmyzsh::Install[$name],
+ unless $ohmyzsh::concat {
+ file_line { "${name}-${theme}-install":
+ path => "${home}/.zshrc",
+ line => "ZSH_THEME=\"${theme}\"",
+ match => '^ZSH_THEME',
+ require => Ohmyzsh::Install[$name],
+ }
+ } else {
+ concat::fragment { "${home}/.zshrc:ZSH_THEME":
+ target => "${home}/.zshrc",
+ content => "ZSH_THEME=\"${theme}\"\n",
+ order => '020',
+ require => Ohmyzsh::Install[$name],
+ }
}
}
diff --git a/metadata.json b/metadata.json
index 5814f44..d31c5d5 100644
--- a/metadata.json
+++ b/metadata.json
@@ -19,6 +19,10 @@
{
"name": "rehan-wget",
"version_requirement": ">= 1.0.0 < 3.0.0"
+ },
+ {
+ "name": "puppetlabs-concat",
+ "version_requirement": ">= 4.1.0 < 10.0.0"
}
],
"operatingsystem_support": [
diff --git a/templates/concat/zshrc-050-update.zsh-template.epp b/templates/concat/zshrc-050-update.zsh-template.epp
new file mode 100644
index 0000000..92b7b04
--- /dev/null
+++ b/templates/concat/zshrc-050-update.zsh-template.epp
@@ -0,0 +1,7 @@
+<%- |
+ Enum[auto, disabled, reminder] $auto_update_mode,
+ Integer[0] $auto_update_frequency,
+| -%>
+### Puppet Concat: zshrc-050-update.zsh-template.epp
+zstyle ':omz:update' mode <%= $auto_update_mode %>
+zstyle ':omz:update' frequency <%= $auto_update_frequency %>