kitchen-ansible 0.45.1 → 0.45.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,72 +1,72 @@
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
+
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,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,60 +1,60 @@
1
- # -*- encoding: utf-8 -*-
2
- #
3
- # Author:: Michael Heap (<m@michaelheap.com>)
4
- # Mark McKinstry
5
- #
6
- # Copyright (C) 2015 Michael Heap
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
- #
20
-
21
- module Kitchen
22
- module Provisioner
23
- module Ansible
24
- class Os
25
- class Fedora < Os
26
- def install_command
27
- <<-INSTALL
28
-
29
- if [ ! $(which ansible) ]; then
30
- #{redhat_yum_repo}
31
- #{update_packages_command}
32
- #{sudo_env('dnf')} -y install #{ansible_package_name} libselinux-python git python2-dnf
33
- fi
34
- INSTALL
35
- end
36
-
37
- def update_packages_command
38
- @config[:update_package_repos] ? "#{sudo_env('dnf')} makecache" : nil
39
- end
40
-
41
- def ansible_package_name
42
- if @config[:ansible_version] == 'latest' || @config[:ansible_version] == nil
43
- "ansible"
44
- else
45
- "ansible#{@config[:ansible_version][0..2]}-#{@config[:ansible_version]}"
46
- end
47
- end
48
-
49
- def redhat_yum_repo
50
- if @config[:ansible_yum_repo]
51
- <<-INSTALL
52
- #{sudo_env('rpm')} -ivh #{@config[:ansible_yum_repo]}
53
- INSTALL
54
- end
55
- end
56
- end
57
- end
58
- end
59
- end
60
- end
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # Author:: Michael Heap (<m@michaelheap.com>)
4
+ # Mark McKinstry
5
+ #
6
+ # Copyright (C) 2015 Michael Heap
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ module Kitchen
22
+ module Provisioner
23
+ module Ansible
24
+ class Os
25
+ class Fedora < Os
26
+ def install_command
27
+ <<-INSTALL
28
+
29
+ if [ ! $(which ansible) ]; then
30
+ #{redhat_yum_repo}
31
+ #{update_packages_command}
32
+ #{sudo_env('dnf')} -y install #{ansible_package_name} libselinux-python git python2-dnf
33
+ fi
34
+ INSTALL
35
+ end
36
+
37
+ def update_packages_command
38
+ @config[:update_package_repos] ? "#{sudo_env('dnf')} makecache" : nil
39
+ end
40
+
41
+ def ansible_package_name
42
+ if @config[:ansible_version] == 'latest' || @config[:ansible_version] == nil
43
+ "ansible"
44
+ else
45
+ "ansible#{@config[:ansible_version][0..2]}-#{@config[:ansible_version]}"
46
+ end
47
+ end
48
+
49
+ def redhat_yum_repo
50
+ if @config[:ansible_yum_repo]
51
+ <<-INSTALL
52
+ #{sudo_env('rpm')} -ivh #{@config[:ansible_yum_repo]}
53
+ INSTALL
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end