Skip to content

Commit 479d954

Browse files
authored
Merge pull request #815 from travis-ci/meat-precise-hostname-move
Extract hostname bits to align with trusty
2 parents 7240241 + 31a4e89 commit 479d954

File tree

2 files changed

+70
-46
lines changed

2 files changed

+70
-46
lines changed

ci_environment/travis_build_environment/recipes/default.rb

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -50,52 +50,7 @@
5050
user "root"
5151
end
5252

53-
bits = (node.kernel.machine =~ /x86_64/ ? 64 : 32)
54-
hostname = case [node[:platform], node[:platform_version]]
55-
when ["ubuntu", "11.04"] then
56-
"natty#{bits}"
57-
when ["ubuntu", "11.10"] then
58-
"oneiric#{bits}"
59-
when ["ubuntu", "12.04"] then
60-
"precise#{bits}"
61-
end
62-
63-
template "/etc/hosts" do
64-
owner "root"
65-
group "root"
66-
mode 0644
67-
variables(:hostname => hostname)
68-
source "etc/hosts.erb"
69-
not_if { !node[:travis_build_environment][:update_hosts] }
70-
end
71-
72-
%w(
73-
/etc/cloud/templates/hosts.debian.tmpl
74-
/etc/cloud/templates/hosts.tmpl
75-
/etc/cloud/templates/hosts.ubuntu.tmpl
76-
).each do |filename|
77-
template filename do
78-
source 'etc/cloud/templates/hosts.tmpl.erb'
79-
owner 'root'
80-
group 'root'
81-
mode 0644
82-
variables(hostname: hostname)
83-
end
84-
end
85-
86-
template "/etc/hostname" do
87-
owner "root"
88-
group "root"
89-
mode 0644
90-
variables(:hostname => hostname)
91-
source "etc/hostname.erb"
92-
not_if { !node[:travis_build_environment][:update_hosts] }
93-
end
94-
95-
execute "hostname #{hostname}" do
96-
user "root"
97-
end
98-
53+
include_recipe 'travis_build_environment::hostname'
9954

10055
template "/etc/security/limits.conf" do
10156
owner "root"
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Cookbook Name:: travis_build_environment
2+
# Recipe:: hostname
3+
# Copyright 2011-2015, Travis CI GmbH <[email protected]>
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
23+
include_recipe 'travis_build_environment::cloud_init'
24+
25+
bits = (node.kernel.machine =~ /x86_64/ ? 64 : 32)
26+
hostname = case [node[:platform], node[:platform_version]]
27+
when ["ubuntu", "11.04"] then
28+
"natty#{bits}"
29+
when ["ubuntu", "11.10"] then
30+
"oneiric#{bits}"
31+
when ["ubuntu", "12.04"] then
32+
"precise#{bits}"
33+
end
34+
35+
template "/etc/hosts" do
36+
owner "root"
37+
group "root"
38+
mode 0644
39+
variables(:hostname => hostname)
40+
source "etc/hosts.erb"
41+
not_if { !node[:travis_build_environment][:update_hosts] }
42+
end
43+
44+
%w(
45+
/etc/cloud/templates/hosts.debian.tmpl
46+
/etc/cloud/templates/hosts.tmpl
47+
/etc/cloud/templates/hosts.ubuntu.tmpl
48+
).each do |filename|
49+
template filename do
50+
source 'etc/cloud/templates/hosts.tmpl.erb'
51+
owner 'root'
52+
group 'root'
53+
mode 0644
54+
variables(hostname: hostname)
55+
end
56+
end
57+
58+
template "/etc/hostname" do
59+
owner "root"
60+
group "root"
61+
mode 0644
62+
variables(:hostname => hostname)
63+
source "etc/hostname.erb"
64+
not_if { !node[:travis_build_environment][:update_hosts] }
65+
end
66+
67+
execute "hostname #{hostname}" do
68+
user "root"
69+
end

0 commit comments

Comments
 (0)