kitchen-ansible 0.43.1 → 0.44.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,69 +1,69 @@
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/amazon'
24
- require 'kitchen/provisioner/ansible/os/suse'
25
-
26
- module Kitchen
27
- module Provisioner
28
- module Ansible
29
- class Os
30
- attr_accessor :name
31
-
32
- def initialize(name, config)
33
- @config = config
34
- @name = name
35
- end
36
-
37
- def self.make(platform, config)
38
- return nil if platform == ''
39
-
40
- case platform
41
- when 'debian', 'ubuntu'
42
- return Debian.new(platform, config)
43
- when 'redhat', 'centos', 'fedora'
44
- return Redhat.new(platform, config)
45
- when 'amazon'
46
- return Amazon.new(platform, config)
47
- when 'suse', 'opensuse', 'sles'
48
- return Suse.new(platform, config)
49
- end
50
-
51
- nil
52
- end
53
-
54
- # Helpers
55
- def sudo_env(pm)
56
- s = @config[:https_proxy] ? "https_proxy=#{@config[:https_proxy]}" : nil
57
- p = @config[:http_proxy] ? "http_proxy=#{@config[:http_proxy]}" : nil
58
- n = @config[:no_proxy] ? "no_proxy=#{@config[:no_proxy]}" : nil
59
- p || s ? "#{sudo('env')} #{p} #{s} #{n} #{pm}" : "#{sudo(pm)}"
60
- end
61
-
62
- # Taken from https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/provisioner/base.rb
63
- def sudo(script)
64
- @config[:sudo] ? "#{@config[:sudo_command]} #{script}" : script
65
- end
66
- end
67
- end
68
- end
69
- 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/amazon'
24
+ require 'kitchen/provisioner/ansible/os/suse'
25
+
26
+ module Kitchen
27
+ module Provisioner
28
+ module Ansible
29
+ class Os
30
+ attr_accessor :name
31
+
32
+ def initialize(name, config)
33
+ @config = config
34
+ @name = name
35
+ end
36
+
37
+ def self.make(platform, config)
38
+ return nil if platform == ''
39
+
40
+ case platform
41
+ when 'debian', 'ubuntu'
42
+ return Debian.new(platform, config)
43
+ when 'redhat', 'centos', 'fedora'
44
+ return Redhat.new(platform, config)
45
+ when 'amazon'
46
+ return Amazon.new(platform, config)
47
+ when 'suse', 'opensuse', 'sles'
48
+ return Suse.new(platform, config)
49
+ end
50
+
51
+ nil
52
+ end
53
+
54
+ # Helpers
55
+ def sudo_env(pm)
56
+ s = @config[:https_proxy] ? "https_proxy=#{@config[:https_proxy]}" : nil
57
+ p = @config[:http_proxy] ? "http_proxy=#{@config[:http_proxy]}" : nil
58
+ n = @config[:no_proxy] ? "no_proxy=#{@config[:no_proxy]}" : nil
59
+ p || s ? "#{sudo('env')} #{p} #{s} #{n} #{pm}" : "#{sudo(pm)}"
60
+ end
61
+
62
+ # Taken from https://github.com/test-kitchen/test-kitchen/blob/master/lib/kitchen/provisioner/base.rb
63
+ def sudo(script)
64
+ @config[:sudo] ? "#{@config[:sudo_command]} #{script}" : script
65
+ end
66
+ end
67
+ end
68
+ end
69
+ 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
@@ -1,69 +1,69 @@
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 Debian < Os
25
- def update_packages_command
26
- @config[:update_package_repos] ? "#{sudo_env('apt-get')} update" : nil
27
- end
28
-
29
- def ansible_debian_version
30
- if @config[:ansible_version] == 'latest' || @config[:ansible_version] == nil
31
- ''
32
- else
33
- "=#{@config[:ansible_version]}"
34
- end
35
- end
36
-
37
- def install_command
38
- <<-INSTALL
39
-
40
- if [ ! $(which ansible) ]; then
41
- #{update_packages_command}
42
-
43
- ## Install apt-utils to silence debconf warning: http://serverfault.com/q/358943/77156
44
- #{sudo_env('apt-get')} -y install apt-utils git
45
-
46
- ## Fix debconf tty warning messages
47
- export DEBIAN_FRONTEND=noninteractive
48
-
49
- ## 13.10, 14.04 include add-apt-repository in software-properties-common
50
- #{sudo_env('apt-get')} -y install software-properties-common
51
-
52
- ## 10.04, 12.04 include add-apt-repository in
53
- #{sudo_env('apt-get')} -y install python-software-properties
54
-
55
- ## 10.04 version of add-apt-repository doesn't accept --yes
56
- ## later versions require interaction from user, so we must specify --yes
57
- ## First try with -y flag, else if it fails, try without.
58
- ## "add-apt-repository: error: no such option: -y" is returned but is ok to ignore, we just retry
59
- #{sudo_env('add-apt-repository')} -y #{@config[:ansible_apt_repo]} || #{sudo_env('add-apt-repository')} #{@config[:ansible_apt_repo]}
60
- #{sudo_env('apt-get')} update
61
- #{sudo_env('apt-get')} -y install ansible#{ansible_debian_version}
62
- fi
63
- INSTALL
64
- end
65
- end
66
- end
67
- end
68
- end
69
- 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 Debian < Os
25
+ def update_packages_command
26
+ @config[:update_package_repos] ? "#{sudo_env('apt-get')} update" : nil
27
+ end
28
+
29
+ def ansible_debian_version
30
+ if @config[:ansible_version] == 'latest' || @config[:ansible_version] == nil
31
+ ''
32
+ else
33
+ "=#{@config[:ansible_version]}"
34
+ end
35
+ end
36
+
37
+ def install_command
38
+ <<-INSTALL
39
+
40
+ if [ ! $(which ansible) ]; then
41
+ #{update_packages_command}
42
+
43
+ ## Install apt-utils to silence debconf warning: http://serverfault.com/q/358943/77156
44
+ #{sudo_env('apt-get')} -y install apt-utils git
45
+
46
+ ## Fix debconf tty warning messages
47
+ export DEBIAN_FRONTEND=noninteractive
48
+
49
+ ## 13.10, 14.04 include add-apt-repository in software-properties-common
50
+ #{sudo_env('apt-get')} -y install software-properties-common
51
+
52
+ ## 10.04, 12.04 include add-apt-repository in
53
+ #{sudo_env('apt-get')} -y install python-software-properties
54
+
55
+ ## 10.04 version of add-apt-repository doesn't accept --yes
56
+ ## later versions require interaction from user, so we must specify --yes
57
+ ## First try with -y flag, else if it fails, try without.
58
+ ## "add-apt-repository: error: no such option: -y" is returned but is ok to ignore, we just retry
59
+ #{sudo_env('add-apt-repository')} -y #{@config[:ansible_apt_repo]} || #{sudo_env('add-apt-repository')} #{@config[:ansible_apt_repo]}
60
+ #{sudo_env('apt-get')} update
61
+ #{sudo_env('apt-get')} -y install ansible#{ansible_debian_version}
62
+ fi
63
+ INSTALL
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,70 +1,70 @@
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 Redhat < Os
25
- def install_command
26
- <<-INSTALL
27
-
28
- if [ ! $(which ansible) ]; then
29
- #{install_epel_repo}
30
- #{redhat_yum_repo}
31
- #{update_packages_command}
32
- #{sudo_env('yum')} -y install #{ansible_package_name} libselinux-python git
33
- fi
34
- INSTALL
35
- end
36
-
37
- def update_packages_command
38
- @config[:update_package_repos] ? "#{sudo_env('yum')} makecache" : nil
39
- end
40
-
41
- def install_epel_repo
42
- @config[:enable_yum_epel] ? sudo_env('yum install epel-release -y') : nil
43
- end
44
-
45
- def ansible_package_name
46
- if @config[:ansible_version] == 'latest' || @config[:ansible_version] == nil
47
- "ansible"
48
- else
49
- "ansible#{@config[:ansible_version][0..2]}-#{@config[:ansible_version]}"
50
- end
51
- end
52
-
53
- def redhat_yum_repo
54
- if @config[:ansible_yum_repo]
55
- <<-INSTALL
56
- #{sudo_env('rpm')} -ivh #{@config[:ansible_yum_repo]}
57
- INSTALL
58
- else
59
- <<-INSTALL
60
- if ! yum repolist epel | grep -q epel; then
61
- #{sudo_env('rpm')} -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-`rpm -E %dist | sed -n 's/.*el\\([0-9]\\).*/\\1/p'`.noarch.rpm
62
- fi
63
- INSTALL
64
- end
65
- end
66
- end
67
- end
68
- end
69
- end
70
- 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 Redhat < Os
25
+ def install_command
26
+ <<-INSTALL
27
+
28
+ if [ ! $(which ansible) ]; then
29
+ #{install_epel_repo}
30
+ #{redhat_yum_repo}
31
+ #{update_packages_command}
32
+ #{sudo_env('yum')} -y install #{ansible_package_name} libselinux-python git
33
+ fi
34
+ INSTALL
35
+ end
36
+
37
+ def update_packages_command
38
+ @config[:update_package_repos] ? "#{sudo_env('yum')} makecache" : nil
39
+ end
40
+
41
+ def install_epel_repo
42
+ @config[:enable_yum_epel] ? sudo_env('yum install epel-release -y') : nil
43
+ end
44
+
45
+ def ansible_package_name
46
+ if @config[:ansible_version] == 'latest' || @config[:ansible_version] == nil
47
+ "ansible"
48
+ else
49
+ "ansible#{@config[:ansible_version][0..2]}-#{@config[:ansible_version]}"
50
+ end
51
+ end
52
+
53
+ def redhat_yum_repo
54
+ if @config[:ansible_yum_repo]
55
+ <<-INSTALL
56
+ #{sudo_env('rpm')} -ivh #{@config[:ansible_yum_repo]}
57
+ INSTALL
58
+ else
59
+ <<-INSTALL
60
+ if ! yum repolist epel | grep -q epel; then
61
+ #{sudo_env('rpm')} -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-`rpm -E %dist | sed -n 's/.*el\\([0-9]\\).*/\\1/p'`.noarch.rpm
62
+ fi
63
+ INSTALL
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end