|
4 | 4 | for_all_oses do |platform, version| |
5 | 5 | context "on #{platform}#{version}" do |
6 | 6 | cached(:cfnbootstrap_version) { '2.0-33' } |
7 | | - cached(:cfnbootstrap_package) { "aws-cfn-bootstrap-py3-#{cfnbootstrap_version}.tar.gz" } |
| 7 | + cached(:arch) { 'x86_64' } |
| 8 | + cached(:s3_url) { 's3://url' } |
| 9 | + cached(:base_dir) { 'base_dir' } |
8 | 10 | cached(:python_version) { "#{node['cluster']['python-version']}" } |
| 11 | + cached(:dependecy_package_name_suffix) do |
| 12 | + if platform == 'amazon' && version == '2' |
| 13 | + "cfn-dependencies" |
| 14 | + else |
| 15 | + "pypi-cfn-dependencies-#{node['cluster']['python-major-minor-version']}-#{arch}" |
| 16 | + end |
| 17 | + end |
| 18 | + cached(:dependecy_folder_name) do |
| 19 | + if platform == 'amazon' && version == '2' |
| 20 | + "cfn" |
| 21 | + else |
| 22 | + dependecy_package_name_suffix |
| 23 | + end |
| 24 | + end |
| 25 | + cached(:cfnbootstrap_package) { "aws-cfn-bootstrap-py3-#{cfnbootstrap_version}.tar.gz" } |
9 | 26 | cached(:system_pyenv_root) { 'system_pyenv_root' } |
10 | 27 | cached(:virtualenv_path) { "system_pyenv_root/versions/#{python_version}/envs/cfn_bootstrap_virtualenv" } |
11 | 28 | cached(:timeout) { 1800 } |
| 29 | + cached(:dependency_bash_code) do |
| 30 | + <<-REQ |
| 31 | + set -e |
| 32 | + tar xzf cfn-dependencies.tgz |
| 33 | + cd #{dependecy_folder_name} |
| 34 | + #{virtualenv_path}/bin/pip install * -f ./ --no-index |
| 35 | + REQ |
| 36 | + end |
12 | 37 |
|
13 | 38 | context "when cfn_bootstrap virtualenv not installed yet" do |
14 | 39 | cached(:chef_run) do |
15 | 40 | runner = runner(platform: platform, version: version) do |node| |
16 | 41 | node.override['cluster']['system_pyenv_root'] = system_pyenv_root |
17 | 42 | node.override['cluster']['region'] = 'non_china' |
| 43 | + node.override['cluster']['base_dir'] = base_dir |
18 | 44 | node.override['cluster']['compute_node_bootstrap_timeout'] = timeout |
| 45 | + node.override['cluster']['artifacts_s3_url'] = s3_url |
| 46 | + node.override['kernel']['machine'] = arch |
19 | 47 | end |
20 | 48 | runner.converge(described_recipe) |
21 | 49 | end |
|
37 | 65 | is_expected.to write_node_attributes('dump node attributes') |
38 | 66 | end |
39 | 67 |
|
| 68 | + it 'downloads cfn_dependecies package from s3' do |
| 69 | + is_expected.to create_if_missing_remote_file("#{base_dir}/cfn-dependencies.tgz") |
| 70 | + .with(source: "#{s3_url}/dependencies/PyPi/#{arch}/#{dependecy_package_name_suffix}.tgz") |
| 71 | + .with(mode: '0644') |
| 72 | + .with(retries: 3) |
| 73 | + .with(retry_delay: 5) |
| 74 | + end |
| 75 | + |
| 76 | + it 'pip installs dependencies' do |
| 77 | + is_expected.to run_bash('pip install') |
| 78 | + .with(user: 'root') |
| 79 | + .with(group: 'root') |
| 80 | + .with(cwd: base_dir) |
| 81 | + .with(code: dependency_bash_code) |
| 82 | + end |
| 83 | + |
40 | 84 | it 'downloads cfn_bootstrap package from s3' do |
41 | 85 | is_expected.to create_remote_file("/tmp/#{cfnbootstrap_package}").with( |
42 | 86 | source: "https://s3.amazonaws.com/cloudformation-examples/#{cfnbootstrap_package}" |
|
48 | 92 | user: 'root', |
49 | 93 | group: 'root', |
50 | 94 | cwd: '/tmp', |
51 | | - code: "#{virtualenv_path}/bin/pip install #{cfnbootstrap_package}", |
| 95 | + code: "#{virtualenv_path}/bin/pip install #{cfnbootstrap_package} --no-build-isolation", |
52 | 96 | creates: "#{virtualenv_path}/bin/cfn-hup" |
53 | 97 | ) |
54 | 98 | end |
|
0 commit comments