kitchen-ansible 0.49.0 → 0.49.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,78 +1,78 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
- # Author:: Fletcher Nichol (<fnichol@nichol.ca>) Neill Turner (<neillwturner@gmail.com>)
4
- #
5
- # Copyright (C) 2013, Fletcher Nichol, Neill Turner
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
-
19
- require 'kitchen/errors'
20
- require 'kitchen/logging'
21
-
22
- module Kitchen
23
- module Provisioner
24
- module Ansible
25
- # Ansible module resolver that uses Librarian-Ansible and a Ansiblefile to
26
- # calculate # dependencies.
27
- #
28
- class Librarian
29
- include Logging
30
-
31
- def initialize(ansiblefile, path, logger = Kitchen.logger)
32
- @ansiblefile = ansiblefile
33
- @path = path
34
- @logger = logger
35
- end
36
-
37
- def self.load!(logger = Kitchen.logger)
38
- load_librarian!(logger)
39
- end
40
-
41
- def resolve
42
- version = ::Librarian::Ansible::VERSION
43
- info("Resolving role dependencies with Librarian-Ansible #{version}...")
44
- debug("Using Ansiblefile from #{ansiblefile}")
45
-
46
- env = ::Librarian::Ansible::Environment.new(
47
- project_path: File.dirname(ansiblefile))
48
- env.config_db.local['path'] = path
49
- ::Librarian::Action::Resolve.new(env).run
50
- ::Librarian::Action::Install.new(env).run
51
- end
52
-
53
- attr_reader :ansiblefile, :path, :logger
54
-
55
- def self.load_librarian!(logger)
56
- first_load = require 'librarian/ansible'
57
- require 'librarian/ansible/environment'
58
- require 'librarian/action/resolve'
59
- require 'librarian/action/install'
60
-
61
- version = ::Librarian::Ansible::VERSION
62
- if first_load
63
- logger.debug("Librarian-Ansible #{version} library loaded")
64
- else
65
- logger.debug("Librarian-Ansible #{version} previously loaded")
66
- end
67
- rescue LoadError => e
68
- logger.fatal("The `librarian-ansible' gem is missing and must be installed" \
69
- ' or cannot be properly activated. Run' \
70
- ' `gem install librarian-ansible` or add the following to your' \
71
- " Gemfile if you are using Bundler: `gem 'librarian-ansible'`.")
72
- raise UserError,
73
- "Could not load or activate Librarian-Ansible (#{e.message})"
74
- end
75
- end
76
- end
77
- end
78
- end
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Fletcher Nichol (<fnichol@nichol.ca>) Neill Turner (<neillwturner@gmail.com>)
4
+ #
5
+ # Copyright (C) 2013, Fletcher Nichol, Neill Turner
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ require 'kitchen/errors'
20
+ require 'kitchen/logging'
21
+
22
+ module Kitchen
23
+ module Provisioner
24
+ module Ansible
25
+ # Ansible module resolver that uses Librarian-Ansible and a Ansiblefile to
26
+ # calculate # dependencies.
27
+ #
28
+ class Librarian
29
+ include Logging
30
+
31
+ def initialize(ansiblefile, path, logger = Kitchen.logger)
32
+ @ansiblefile = ansiblefile
33
+ @path = path
34
+ @logger = logger
35
+ end
36
+
37
+ def self.load!(logger = Kitchen.logger)
38
+ load_librarian!(logger)
39
+ end
40
+
41
+ def resolve
42
+ version = ::Librarian::Ansible::VERSION
43
+ info("Resolving role dependencies with Librarian-Ansible #{version}...")
44
+ debug("Using Ansiblefile from #{ansiblefile}")
45
+
46
+ env = ::Librarian::Ansible::Environment.new(
47
+ project_path: File.dirname(ansiblefile))
48
+ env.config_db.local['path'] = path
49
+ ::Librarian::Action::Resolve.new(env).run
50
+ ::Librarian::Action::Install.new(env).run
51
+ end
52
+
53
+ attr_reader :ansiblefile, :path, :logger
54
+
55
+ def self.load_librarian!(logger)
56
+ first_load = require 'librarian/ansible'
57
+ require 'librarian/ansible/environment'
58
+ require 'librarian/action/resolve'
59
+ require 'librarian/action/install'
60
+
61
+ version = ::Librarian::Ansible::VERSION
62
+ if first_load
63
+ logger.debug("Librarian-Ansible #{version} library loaded")
64
+ else
65
+ logger.debug("Librarian-Ansible #{version} previously loaded")
66
+ end
67
+ rescue LoadError => e
68
+ logger.fatal("The `librarian-ansible' gem is missing and must be installed" \
69
+ ' or cannot be properly activated. Run' \
70
+ ' `gem install librarian-ansible` or add the following to your' \
71
+ " Gemfile if you are using Bundler: `gem 'librarian-ansible'`.")
72
+ raise UserError,
73
+ "Could not load or activate Librarian-Ansible (#{e.message})"
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -1,84 +1,84 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
- # Author:: Michael Heap (<m@michaelheap.com>)
4
- #
5
- # Copyright (C) 2015 Michael Heap
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
-
20
- require 'json'
21
- require 'kitchen/provisioner/ansible/os/debian'
22
- require 'kitchen/provisioner/ansible/os/redhat'
23
- require 'kitchen/provisioner/ansible/os/fedora'
24
- require 'kitchen/provisioner/ansible/os/amazon'
25
- require 'kitchen/provisioner/ansible/os/suse'
26
- require 'kitchen/provisioner/ansible/os/darwin'
27
- require 'kitchen/provisioner/ansible/os/alpine'
28
- require 'kitchen/provisioner/ansible/os/openbsd'
29
- require 'kitchen/provisioner/ansible/os/freebsd'
30
-
31
- module Kitchen
32
- module Provisioner
33
- module Ansible
34
- class Os
35
- attr_accessor :name
36
-
37
- def initialize(name, config)
38
- @config = config
39
- @name = name
40
- end
41
-
42
- def self.make(platform, config)
43
- return nil if platform == ''
44
-
45
- case platform
46
- when 'debian', 'ubuntu'
47
- return Debian.new(platform, config)
48
- when 'redhat', 'centos'
49
- return Redhat.new(platform, config)
50
- when 'fedora'
51
- return Fedora.new(platform, config)
52
- when 'amazon'
53
- return Amazon.new(platform, config)
54
- when 'suse', 'opensuse', 'sles'
55
- return Suse.new(platform, config)
56
- when 'darwin', 'mac', 'macos', 'macosx'
57
- return Darwin.new(platform, config)
58
- when 'alpine'
59
- return Alpine.new(platform, config)
60
- when 'openbsd'
61
- return Openbsd.new(platform, config)
62
- when 'freebsd'
63
- return Freebsd.new(platform, config)
64
- end
65
-
66
- nil
67
- end
68
-
69
- # Helpers
70
- def sudo_env(pm)
71
- s = @config[:https_proxy] ? "https_proxy=#{@config[:https_proxy]}" : nil
72
- p = @config[:http_proxy] ? "http_proxy=#{@config[:http_proxy]}" : nil
73
- n = @config[:no_proxy] ? "no_proxy=#{@config[:no_proxy]}" : nil
74
- p || s ? "#{sudo('env')} #{p} #{s} #{n} #{pm}" : "#{sudo(pm)}"
75
- end
76
-
77
- # Taken from https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/provisioner/base.rb
78
- def sudo(script)
79
- @config[:sudo] ? "#{@config[:sudo_command]} #{script}" : script
80
- end
81
- end
82
- end
83
- end
84
- end
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Michael Heap (<m@michaelheap.com>)
4
+ #
5
+ # Copyright (C) 2015 Michael Heap
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ require 'json'
21
+ require 'kitchen/provisioner/ansible/os/debian'
22
+ require 'kitchen/provisioner/ansible/os/redhat'
23
+ require 'kitchen/provisioner/ansible/os/fedora'
24
+ require 'kitchen/provisioner/ansible/os/amazon'
25
+ require 'kitchen/provisioner/ansible/os/suse'
26
+ require 'kitchen/provisioner/ansible/os/darwin'
27
+ require 'kitchen/provisioner/ansible/os/alpine'
28
+ require 'kitchen/provisioner/ansible/os/openbsd'
29
+ require 'kitchen/provisioner/ansible/os/freebsd'
30
+
31
+ module Kitchen
32
+ module Provisioner
33
+ module Ansible
34
+ class Os
35
+ attr_accessor :name
36
+
37
+ def initialize(name, config)
38
+ @config = config
39
+ @name = name
40
+ end
41
+
42
+ def self.make(platform, config)
43
+ return nil if platform == ''
44
+
45
+ case platform
46
+ when 'debian', 'ubuntu'
47
+ return Debian.new(platform, config)
48
+ when 'redhat', 'centos'
49
+ return Redhat.new(platform, config)
50
+ when 'fedora'
51
+ return Fedora.new(platform, config)
52
+ when 'amazon'
53
+ return Amazon.new(platform, config)
54
+ when 'suse', 'opensuse', 'sles'
55
+ return Suse.new(platform, config)
56
+ when 'darwin', 'mac', 'macos', 'macosx'
57
+ return Darwin.new(platform, config)
58
+ when 'alpine'
59
+ return Alpine.new(platform, config)
60
+ when 'openbsd'
61
+ return Openbsd.new(platform, config)
62
+ when 'freebsd'
63
+ return Freebsd.new(platform, config)
64
+ end
65
+
66
+ nil
67
+ end
68
+
69
+ # Helpers
70
+ def sudo_env(pm)
71
+ s = @config[:https_proxy] ? "https_proxy=#{@config[:https_proxy]}" : nil
72
+ p = @config[:http_proxy] ? "http_proxy=#{@config[:http_proxy]}" : nil
73
+ n = @config[:no_proxy] ? "no_proxy=#{@config[:no_proxy]}" : nil
74
+ p || s ? "#{sudo('env')} #{p} #{s} #{n} #{pm}" : "#{sudo(pm)}"
75
+ end
76
+
77
+ # Taken from https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/provisioner/base.rb
78
+ def sudo(script)
79
+ @config[:sudo] ? "#{@config[:sudo_command]} #{script}" : script
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -1,42 +1,42 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
- # Author:: Martin Etmajer (<martin@etmajer.com>)
4
- #
5
- # Copyright (C) 2016 Martin Etmajer
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
-
20
- module Kitchen
21
- module Provisioner
22
- module Ansible
23
- class Os
24
- class Alpine < Os
25
- def update_packages_command
26
- @config[:update_package_repos] ? "#{sudo_env('apk')} update" : nil
27
- end
28
-
29
- def install_command
30
- <<-INSTALL
31
-
32
- if [ ! $(which ansible) ]; then
33
- #{update_packages_command}
34
- #{sudo_env('apk')} add ansible git
35
- fi
36
- INSTALL
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Martin Etmajer (<martin@etmajer.com>)
4
+ #
5
+ # Copyright (C) 2016 Martin Etmajer
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ module Kitchen
21
+ module Provisioner
22
+ module Ansible
23
+ class Os
24
+ class Alpine < Os
25
+ def update_packages_command
26
+ @config[:update_package_repos] ? "#{sudo_env('apk')} update" : nil
27
+ end
28
+
29
+ def install_command
30
+ <<-INSTALL
31
+
32
+ if [ ! $(which ansible) ]; then
33
+ #{update_packages_command}
34
+ #{sudo_env('apk')} add ansible git
35
+ fi
36
+ INSTALL
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,42 +1,42 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
- # Author:: Michael Heap (<m@michaelheap.com>)
4
- #
5
- # Copyright (C) 2015 Michael Heap
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
-
20
- module Kitchen
21
- module Provisioner
22
- module Ansible
23
- class Os
24
- class Amazon < Redhat
25
- def install_command
26
- <<-INSTALL
27
-
28
- if [ ! $(which ansible) ]; then
29
- #{install_epel_repo}
30
- #{sudo_env('yum-config-manager')} --enable epel/x86_64
31
- #{sudo_env('yum')} -y install #{ansible_package_name} git
32
- #{sudo_env('alternatives')} --set python /usr/bin/python2.6
33
- #{sudo_env('yum')} clean all
34
- #{sudo_env('yum')} install yum-python26 -y
35
- fi
36
- INSTALL
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Michael Heap (<m@michaelheap.com>)
4
+ #
5
+ # Copyright (C) 2015 Michael Heap
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ module Kitchen
21
+ module Provisioner
22
+ module Ansible
23
+ class Os
24
+ class Amazon < Redhat
25
+ def install_command
26
+ <<-INSTALL
27
+
28
+ if [ ! $(which ansible) ]; then
29
+ #{install_epel_repo}
30
+ #{sudo_env('yum-config-manager')} --enable epel/x86_64
31
+ #{sudo_env('yum')} -y install #{ansible_package_name} git
32
+ #{sudo_env('alternatives')} --set python /usr/bin/python2.6
33
+ #{sudo_env('yum')} clean all
34
+ #{sudo_env('yum')} install yum-python26 -y
35
+ fi
36
+ INSTALL
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end