kitchen-ansible 0.45.4 → 0.45.5

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,72 +1,78 @@
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
-
27
- module Kitchen
28
- module Provisioner
29
- module Ansible
30
- class Os
31
- attr_accessor :name
32
-
33
- def initialize(name, config)
34
- @config = config
35
- @name = name
36
- end
37
-
38
- def self.make(platform, config)
39
- return nil if platform == ''
40
-
41
- case platform
42
- when 'debian', 'ubuntu'
43
- return Debian.new(platform, config)
44
- when 'redhat', 'centos'
45
- return Redhat.new(platform, config)
46
- when 'fedora'
47
- return Fedora.new(platform, config)
48
- when 'amazon'
49
- return Amazon.new(platform, config)
50
- when 'suse', 'opensuse', 'sles'
51
- return Suse.new(platform, config)
52
- end
53
-
54
- nil
55
- end
56
-
57
- # Helpers
58
- def sudo_env(pm)
59
- s = @config[:https_proxy] ? "https_proxy=#{@config[:https_proxy]}" : nil
60
- p = @config[:http_proxy] ? "http_proxy=#{@config[:http_proxy]}" : nil
61
- n = @config[:no_proxy] ? "no_proxy=#{@config[:no_proxy]}" : nil
62
- p || s ? "#{sudo('env')} #{p} #{s} #{n} #{pm}" : "#{sudo(pm)}"
63
- end
64
-
65
- # Taken from https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/provisioner/base.rb
66
- def sudo(script)
67
- @config[:sudo] ? "#{@config[:sudo_command]} #{script}" : script
68
- end
69
- end
70
- end
71
- end
72
- 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
+
29
+ module Kitchen
30
+ module Provisioner
31
+ module Ansible
32
+ class Os
33
+ attr_accessor :name
34
+
35
+ def initialize(name, config)
36
+ @config = config
37
+ @name = name
38
+ end
39
+
40
+ def self.make(platform, config)
41
+ return nil if platform == ''
42
+
43
+ case platform
44
+ when 'debian', 'ubuntu'
45
+ return Debian.new(platform, config)
46
+ when 'redhat', 'centos'
47
+ return Redhat.new(platform, config)
48
+ when 'fedora'
49
+ return Fedora.new(platform, config)
50
+ when 'amazon'
51
+ return Amazon.new(platform, config)
52
+ when 'suse', 'opensuse', 'sles'
53
+ return Suse.new(platform, config)
54
+ when 'darwin', 'mac', 'macos', 'macosx'
55
+ return Darwin.new(platform, config)
56
+ when 'alpine'
57
+ return Alpine.new(platform, config)
58
+ end
59
+
60
+ nil
61
+ end
62
+
63
+ # Helpers
64
+ def sudo_env(pm)
65
+ s = @config[:https_proxy] ? "https_proxy=#{@config[:https_proxy]}" : nil
66
+ p = @config[:http_proxy] ? "http_proxy=#{@config[:http_proxy]}" : nil
67
+ n = @config[:no_proxy] ? "no_proxy=#{@config[:no_proxy]}" : nil
68
+ p || s ? "#{sudo('env')} #{p} #{s} #{n} #{pm}" : "#{sudo(pm)}"
69
+ end
70
+
71
+ # Taken from https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/provisioner/base.rb
72
+ def sudo(script)
73
+ @config[:sudo] ? "#{@config[:sudo_command]} #{script}" : script
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +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,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
@@ -0,0 +1,37 @@
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 Darwin < Os
25
+
26
+ def install_command
27
+ <<-INSTALL
28
+ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
29
+ /usr/local/bin/brew install ansible
30
+ INSTALL
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end