1
3
Puppet::Face.define(:module, '1.0.0') do
3
summary "Install a module from a repository or release archive."
5
summary "Install a module from the Puppet Forge or a release archive."
5
Install a module from a release archive file on-disk or by downloading
6
one from a repository. Unpack the archive into the install directory
7
specified by the --install-dir option, which defaults to
8
#{Puppet.settings[:modulepath].split(File::PATH_SEPARATOR).first}
7
Installs a module from the Puppet Forge or from a release archive file.
9
The specified module will be installed into the directory
10
specified with the `--target-dir` option, which defaults to
11
#{Puppet.settings[:modulepath].split(File::PATH_SEPARATOR).first}.
11
14
returns "Pathname object representing the path to the installed module."
14
Install a module from the default repository:
16
$ puppet module install puppetlabs/vcsrepo
17
notice: Installing puppetlabs-vcsrepo-0.0.4.tar.gz to /etc/puppet/modules/vcsrepo
18
/etc/puppet/modules/vcsrepo
20
Install a specific module version from a repository:
22
$ puppet module install puppetlabs/vcsrepo -v 0.0.4
23
notice: Installing puppetlabs-vcsrepo-0.0.4.tar.gz to /etc/puppet/modules/vcsrepo
24
/etc/puppet/modules/vcsrepo
19
$ puppet module install puppetlabs-vcsrepo
20
Preparing to install into /etc/puppet/modules ...
21
Downloading from http://forge.puppetlabs.com ...
22
Installing -- do not interrupt ...
24
└── puppetlabs-vcsrepo (v0.0.4)
26
Install a module to a specific environment:
28
$ puppet module install puppetlabs-vcsrepo --environment development
29
Preparing to install into /etc/puppet/environments/development/modules ...
30
Downloading from http://forge.puppetlabs.com ...
31
Installing -- do not interrupt ...
32
/etc/puppet/environments/development/modules
33
└── puppetlabs-vcsrepo (v0.0.4)
35
Install a specific module version:
37
$ puppet module install puppetlabs-vcsrepo -v 0.0.4
38
Preparing to install into /etc/puppet/modules ...
39
Downloading from http://forge.puppetlabs.com ...
40
Installing -- do not interrupt ...
42
└── puppetlabs-vcsrepo (v0.0.4)
26
44
Install a module into a specific directory:
28
$ puppet module install puppetlabs/vcsrepo --install-dir=/usr/share/puppet/modules
29
notice: Installing puppetlabs-vcsrepo-0.0.4.tar.gz to /usr/share/puppet/modules/vcsrepo
30
/usr/share/puppet/modules/vcsrepo
46
$ puppet module install puppetlabs-vcsrepo --target-dir=/usr/share/puppet/modules
47
Preparing to install into /usr/share/puppet/modules ...
48
Downloading from http://forge.puppetlabs.com ...
49
Installing -- do not interrupt ...
50
/usr/share/puppet/modules
51
└── puppetlabs-vcsrepo (v0.0.4)
53
Install a module into a specific directory and check for dependencies in other directories:
55
$ puppet module install puppetlabs-vcsrepo --target-dir=/usr/share/puppet/modules --modulepath /etc/puppet/modules
56
Preparing to install into /usr/share/puppet/modules ...
57
Downloading from http://forge.puppetlabs.com ...
58
Installing -- do not interrupt ...
59
/usr/share/puppet/modules
60
└── puppetlabs-vcsrepo (v0.0.4)
32
62
Install a module from a release archive:
34
64
$ puppet module install puppetlabs-vcsrepo-0.0.4.tar.gz
35
notice: Installing puppetlabs-vcsrepo-0.0.4.tar.gz to /etc/puppet/modules/vcsrepo
36
/etc/puppet/modules/vcsrepo
65
Preparing to install into /etc/puppet/modules ...
66
Downloading from http://forge.puppetlabs.com ...
67
Installing -- do not interrupt ...
69
└── puppetlabs-vcsrepo (v0.0.4)
71
Install a module from a release archive and ignore dependencies:
73
$ puppet module install puppetlabs-vcsrepo-0.0.4.tar.gz --ignore-dependencies
74
Preparing to install into /etc/puppet/modules ...
75
Installing -- do not interrupt ...
77
└── puppetlabs-vcsrepo (v0.0.4)
48
option "--install-dir=", "-i=" do
49
default_to { Puppet.settings[:modulepath].split(File::PATH_SEPARATOR).first }
90
option "--target-dir DIR", "-i DIR" do
50
91
summary "The directory into which modules are installed."
52
The directory into which modules are installed, defaults to the first
93
The directory into which modules are installed; defaults to the first
53
94
directory in the modulepath.
57
option "--module-repository=", "-r=" do
58
default_to { Puppet.settings[:module_repository] }
59
summary "Module repository to use."
61
Module repository to use.
65
option "--version=", "-v=" do
96
Specifying this option will change the installation directory, and
97
will use the existing modulepath when checking for dependencies. If
98
you wish to check a different set of directories for dependencies, you
99
must also use the `--environment` or `--modulepath` options.
103
option "--ignore-dependencies" do
104
summary "Do not attempt to install dependencies"
106
Do not attempt to install dependencies.
110
option "--modulepath MODULEPATH" do
111
default_to { Puppet.settings[:modulepath] }
112
summary "Which directories to look for modules in"
114
The list of directories to check for modules. When installing a new
115
module, this setting determines where the module tool will look for
116
its dependencies. If the `--target dir` option is not specified, the
117
first directory in the modulepath will also be used as the install
120
When installing a module into an environment whose modulepath is
121
specified in puppet.conf, you can use the `--environment` option
122
instead, and its modulepath will be used automatically.
124
This setting should be a list of directories separated by the path
125
separator character. (The path separator is `:` on Unix-like platforms
130
option "--version VER", "-v VER" do
66
131
summary "Module version to install."
67
132
description <<-EOT
68
Module version to install, can be a requirement string, eg '>= 1.0.3',
69
defaults to latest version.
133
Module version to install; can be an exact version or a requirement string,
134
eg '>= 1.0.3'. Defaults to latest version.
138
option "--environment NAME" do
139
default_to { "production" }
140
summary "The target environment to install modules into."
142
The target environment to install modules into. Only applicable if
143
multiple environments (with different modulepaths) have been
144
configured in puppet.conf.
73
148
when_invoked do |name, options|
74
Puppet::Module::Tool::Applications::Installer.run(name, options)
149
sep = File::PATH_SEPARATOR
150
if options[:target_dir]
151
options[:target_dir] = File.expand_path(options[:target_dir])
152
options[:modulepath] = "#{options[:target_dir]}#{sep}#{options[:modulepath]}"
155
Puppet.settings[:modulepath] = options[:modulepath]
156
options[:target_dir] = Puppet.settings[:modulepath].split(sep).first
158
Puppet.notice "Preparing to install into #{options[:target_dir]} ..."
159
Puppet::ModuleTool::Applications::Installer.run(name, options)
77
when_rendering :console do |return_value|
78
# Get the string representation of the Pathname object and print it to
162
when_rendering :console do |return_value, name, options|
163
if return_value[:result] == :failure
164
Puppet.err(return_value[:error][:multiline])
167
tree = Puppet::ModuleTool.build_tree(return_value[:installed_modules], return_value[:install_dir])
168
return_value[:install_dir] + "\n" +
169
Puppet::ModuleTool.format_tree(tree)