~ubuntu-branches/ubuntu/quantal/puppet/quantal

« back to all changes in this revision

Viewing changes to lib/puppet/face/module/install.rb

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-07-14 01:56:30 UTC
  • mfrom: (1.1.29) (3.1.43 sid)
  • Revision ID: package-import@ubuntu.com-20120714015630-ntj41rkvkq4zph4y
Tags: 2.7.18-1ubuntu1
* Resynchronise with Debian. (LP: #1023931) Remaining changes:
  - debian/puppetmaster-passenger.postinst: Make sure we error if puppet
    config print doesn't work
  - debian/puppetmaster-passenger.postinst: Ensure upgrades from
    <= 2.7.11-1 fixup passenger apache configuration.
* Dropped upstreamed patches:
  - debian/patches/CVE-2012-1906_CVE-2012-1986_to_CVE-2012-1989.patch
  - debian/patches/puppet-12844
  - debian/patches/2.7.17-Puppet-July-2012-CVE-fixes.patch
* Drop Build-Depends on ruby-rspec (in universe):
  - debian/control: remove ruby-rspec from Build-Depends
  - debian/patches/no-rspec.patch: make Rakefile work anyway if rspec
    isn't installed so we can use it in debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# encoding: UTF-8
 
2
 
1
3
Puppet::Face.define(:module, '1.0.0') do
2
4
  action(:install) 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."
4
6
    description <<-EOT
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.
 
8
 
 
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}.
9
12
    EOT
10
13
 
11
14
    returns "Pathname object representing the path to the installed module."
12
15
 
13
16
    examples <<-EOT
14
 
      Install a module from the default repository:
15
 
 
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
19
 
 
20
 
      Install a specific module version from a repository:
21
 
 
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
 
17
      Install a module:
 
18
 
 
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 ...
 
23
      /etc/puppet/modules
 
24
      └── puppetlabs-vcsrepo (v0.0.4)
 
25
 
 
26
      Install a module to a specific environment:
 
27
 
 
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)
 
34
 
 
35
      Install a specific module version:
 
36
 
 
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 ...
 
41
      /etc/puppet/modules
 
42
      └── puppetlabs-vcsrepo (v0.0.4)
25
43
 
26
44
      Install a module into a specific directory:
27
45
 
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)
 
52
 
 
53
      Install a module into a specific directory and check for dependencies in other directories:
 
54
 
 
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)
31
61
 
32
62
      Install a module from a release archive:
33
63
 
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 ...
 
68
      /etc/puppet/modules
 
69
      └── puppetlabs-vcsrepo (v0.0.4)
 
70
 
 
71
      Install a module from a release archive and ignore dependencies:
 
72
 
 
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 ...
 
76
      /etc/puppet/modules
 
77
      └── puppetlabs-vcsrepo (v0.0.4)
 
78
 
37
79
    EOT
38
80
 
39
81
    arguments "<name>"
45
87
      EOT
46
88
    end
47
89
 
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."
51
92
      description <<-EOT
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.
54
 
      EOT
55
 
    end
56
 
 
57
 
    option "--module-repository=", "-r=" do
58
 
      default_to { Puppet.settings[:module_repository] }
59
 
      summary "Module repository to use."
60
 
      description <<-EOT
61
 
        Module repository to use.
62
 
      EOT
63
 
    end
64
 
 
65
 
    option "--version=", "-v=" do
 
95
 
 
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.
 
100
      EOT
 
101
    end
 
102
 
 
103
    option "--ignore-dependencies" do
 
104
      summary "Do not attempt to install dependencies"
 
105
      description <<-EOT
 
106
        Do not attempt to install dependencies.
 
107
      EOT
 
108
    end
 
109
 
 
110
    option "--modulepath MODULEPATH" do
 
111
      default_to { Puppet.settings[:modulepath] }
 
112
      summary "Which directories to look for modules in"
 
113
      description <<-EOT
 
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
 
118
        directory.
 
119
 
 
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.
 
123
 
 
124
        This setting should be a list of directories separated by the path
 
125
        separator character. (The path separator is `:` on Unix-like platforms
 
126
        and `;` on Windows.)
 
127
      EOT
 
128
    end
 
129
 
 
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.
 
135
      EOT
 
136
    end
 
137
 
 
138
    option "--environment NAME" do
 
139
      default_to { "production" }
 
140
      summary "The target environment to install modules into."
 
141
      description <<-EOT
 
142
        The target environment to install modules into. Only applicable if
 
143
        multiple environments (with different modulepaths) have been
 
144
        configured in puppet.conf.
70
145
      EOT
71
146
    end
72
147
 
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]}"
 
153
      end
 
154
 
 
155
      Puppet.settings[:modulepath] = options[:modulepath]
 
156
      options[:target_dir] = Puppet.settings[:modulepath].split(sep).first
 
157
 
 
158
      Puppet.notice "Preparing to install into #{options[:target_dir]} ..."
 
159
      Puppet::ModuleTool::Applications::Installer.run(name, options)
75
160
    end
76
161
 
77
 
    when_rendering :console do |return_value|
78
 
      # Get the string representation of the Pathname object and print it to
79
 
      # the console.
80
 
      return_value.to_s
 
162
    when_rendering :console do |return_value, name, options|
 
163
      if return_value[:result] == :failure
 
164
        Puppet.err(return_value[:error][:multiline])
 
165
        exit 1
 
166
      else
 
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)
 
170
      end
81
171
    end
82
172
  end
83
173
end