From f5f43c2b1fd0d14baad000e58f1907de340f5031 Mon Sep 17 00:00:00 2001 From: alex501212 Date: Tue, 22 Oct 2024 17:03:06 +0100 Subject: [PATCH 1/7] remove puppet version pin from gemfile --- Gemfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Gemfile b/Gemfile index 78e74f37dc..9847ad465a 100644 --- a/Gemfile +++ b/Gemfile @@ -39,6 +39,3 @@ local_gemfile = File.join(__dir__, 'Gemfile.local') if File.exist? local_gemfile eval_gemfile local_gemfile end - -# TODO: remove this pin once we solve PE-35920 -gem "puppet", '~> 7.24' From 335bbb0f9188ace8cf2536d48865833c55c574c9 Mon Sep 17 00:00:00 2001 From: alex501212 Date: Wed, 30 Oct 2024 15:59:32 +0000 Subject: [PATCH 2/7] update test to return value instead of error --- spec/integration/lookup_spec.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/spec/integration/lookup_spec.rb b/spec/integration/lookup_spec.rb index 40bd82395b..828898e1ac 100644 --- a/spec/integration/lookup_spec.rb +++ b/spec/integration/lookup_spec.rb @@ -94,13 +94,9 @@ context 'with interpolations' do let(:hiera_config) { File.join(project, 'hiera_interpolations.yaml') } - - it 'returns an error' do + it 'returns a value' do result = run_cli_json(cli_command + %w[key=test::interpolations]) - expect(result).to include( - 'kind' => 'bolt/pal-error', - 'msg' => /Interpolations are not supported in lookups/ - ) + expect(result).to eq('test::interpolations data/common.yaml') end end From 0b92e5563833946bfa8b8a25fd69ec07b448cfe7 Mon Sep 17 00:00:00 2001 From: alex501212 Date: Wed, 30 Oct 2024 16:57:17 +0000 Subject: [PATCH 3/7] revert last commit --- spec/integration/lookup_spec.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/integration/lookup_spec.rb b/spec/integration/lookup_spec.rb index 828898e1ac..40bd82395b 100644 --- a/spec/integration/lookup_spec.rb +++ b/spec/integration/lookup_spec.rb @@ -94,9 +94,13 @@ context 'with interpolations' do let(:hiera_config) { File.join(project, 'hiera_interpolations.yaml') } - it 'returns a value' do + + it 'returns an error' do result = run_cli_json(cli_command + %w[key=test::interpolations]) - expect(result).to eq('test::interpolations data/common.yaml') + expect(result).to include( + 'kind' => 'bolt/pal-error', + 'msg' => /Interpolations are not supported in lookups/ + ) end end From 9990d8456cda4ac60c7774753e5da48e76c5f0e0 Mon Sep 17 00:00:00 2001 From: alex501212 Date: Wed, 6 Nov 2024 12:04:59 +0000 Subject: [PATCH 4/7] remove ruby 2 tests and update lookup spec tests --- .github/workflows/apply.yaml | 2 +- .github/workflows/bolt_server.yaml | 2 +- .github/workflows/bolt_spec.yaml | 2 +- .github/workflows/docker_transport.yaml | 2 +- .github/workflows/linux.yaml | 2 +- .github/workflows/local_transport.yaml | 2 +- .github/workflows/modules.yaml | 2 +- .github/workflows/orch_transport.yaml | 2 +- .github/workflows/ssh_transport.yaml | 2 +- .github/workflows/unit.yaml | 2 +- .github/workflows/windows.yaml | 2 +- .github/workflows/winrm_transport.yaml | 2 +- spec/integration/lookup_spec.rb | 19 ++++++++----------- 13 files changed, 20 insertions(+), 23 deletions(-) diff --git a/.github/workflows/apply.yaml b/.github/workflows/apply.yaml index a18516ae40..a13052d512 100644 --- a/.github/workflows/apply.yaml +++ b/.github/workflows/apply.yaml @@ -27,7 +27,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - ruby: [2.7, 3.1] + ruby: [3.1] runs-on: ${{ matrix.os }} steps: - name: Checkout repository diff --git a/.github/workflows/bolt_server.yaml b/.github/workflows/bolt_server.yaml index c03b2035ea..d786a6beb1 100644 --- a/.github/workflows/bolt_server.yaml +++ b/.github/workflows/bolt_server.yaml @@ -28,7 +28,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - ruby: [2.7, 3.1] + ruby: [3.1] runs-on: ${{ matrix.os }} steps: - name: Checkout repository diff --git a/.github/workflows/bolt_spec.yaml b/.github/workflows/bolt_spec.yaml index ea381f3887..ab1c2f5ca1 100644 --- a/.github/workflows/bolt_spec.yaml +++ b/.github/workflows/bolt_spec.yaml @@ -28,7 +28,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - ruby: [2.7, 3.1] + ruby: [3.1] runs-on: ${{ matrix.os }} steps: - name: Checkout repository diff --git a/.github/workflows/docker_transport.yaml b/.github/workflows/docker_transport.yaml index 007c3c0ce7..e2c96e0046 100644 --- a/.github/workflows/docker_transport.yaml +++ b/.github/workflows/docker_transport.yaml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: [2.7, 3.1] + ruby: [3.1] steps: - name: Checkout repository uses: actions/checkout@v2 diff --git a/.github/workflows/linux.yaml b/.github/workflows/linux.yaml index 070898b36c..6bd6e7f66e 100644 --- a/.github/workflows/linux.yaml +++ b/.github/workflows/linux.yaml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: [2.7, 3.1] + ruby: [3.1] steps: - name: Checkout repository uses: actions/checkout@v2 diff --git a/.github/workflows/local_transport.yaml b/.github/workflows/local_transport.yaml index c06b429c02..7bed4a68ee 100644 --- a/.github/workflows/local_transport.yaml +++ b/.github/workflows/local_transport.yaml @@ -27,7 +27,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - ruby: [2.7, 3.1] + ruby: [3.1] runs-on: ${{ matrix.os }} steps: - name: Checkout repository diff --git a/.github/workflows/modules.yaml b/.github/workflows/modules.yaml index 61f7327402..1d59b51f71 100644 --- a/.github/workflows/modules.yaml +++ b/.github/workflows/modules.yaml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: [2.7, 3.1] + ruby: [3.1] steps: - name: Checkout repository uses: actions/checkout@v2 diff --git a/.github/workflows/orch_transport.yaml b/.github/workflows/orch_transport.yaml index b91d819d53..1894dfe950 100644 --- a/.github/workflows/orch_transport.yaml +++ b/.github/workflows/orch_transport.yaml @@ -27,7 +27,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - ruby: [2.7, 3.1] + ruby: [3.1] runs-on: ${{ matrix.os }} steps: - name: Checkout repository diff --git a/.github/workflows/ssh_transport.yaml b/.github/workflows/ssh_transport.yaml index 951ea59ed2..2f73929661 100644 --- a/.github/workflows/ssh_transport.yaml +++ b/.github/workflows/ssh_transport.yaml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: [2.7, 3.1] + ruby: [3.1] steps: - name: Checkout repository uses: actions/checkout@v2 diff --git a/.github/workflows/unit.yaml b/.github/workflows/unit.yaml index 560eccb10c..62e993b902 100644 --- a/.github/workflows/unit.yaml +++ b/.github/workflows/unit.yaml @@ -24,7 +24,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - ruby: [2.7, 3.1] + ruby: [3.1] runs-on: ${{ matrix.os }} steps: - name: Checkout repository diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml index c441229e97..c052f2194c 100644 --- a/.github/workflows/windows.yaml +++ b/.github/workflows/windows.yaml @@ -27,7 +27,7 @@ jobs: runs-on: windows-latest strategy: matrix: - ruby: [2.7, 3.1] + ruby: [3.1] env: WINDOWS_AGENTS: true steps: diff --git a/.github/workflows/winrm_transport.yaml b/.github/workflows/winrm_transport.yaml index 061ac8df7a..12ca6b6648 100644 --- a/.github/workflows/winrm_transport.yaml +++ b/.github/workflows/winrm_transport.yaml @@ -27,7 +27,7 @@ jobs: runs-on: windows-latest strategy: matrix: - ruby: [2.7, 3.1] + ruby: [3.1] steps: - name: Checkout repository uses: actions/checkout@v2 diff --git a/spec/integration/lookup_spec.rb b/spec/integration/lookup_spec.rb index 40bd82395b..cfef94d179 100644 --- a/spec/integration/lookup_spec.rb +++ b/spec/integration/lookup_spec.rb @@ -92,15 +92,12 @@ end end - context 'with interpolations' do + context 'when context is not available' do let(:hiera_config) { File.join(project, 'hiera_interpolations.yaml') } - it 'returns an error' do + it 'returns the default value' do result = run_cli_json(cli_command + %w[key=test::interpolations]) - expect(result).to include( - 'kind' => 'bolt/pal-error', - 'msg' => /Interpolations are not supported in lookups/ - ) + expect(result).to eq('test::interpolations data/common.yaml') end end @@ -159,11 +156,11 @@ let(:plan) { 'test::plan_lookup' } let(:uri) { 'localhost' } - it 'raises a validation error' do + it 'errors with a missing key' do result = run_cli_json(cli_command + %W[-t #{uri}]) expect(result).to include( 'kind' => 'bolt/pal-error', - 'msg' => /Interpolations are not supported in lookups/ + 'msg' => "Function lookup() did not find a value for the name 'pop'" ) end end @@ -307,9 +304,9 @@ context 'with invalid plan_hierarchy' do let(:hiera_config) { File.join(project, 'plan_hiera_facts.yaml') } - it 'raises a validation error' do - expect { run_cli_json(%w[lookup environment] + opts) } - .to raise_error(Bolt::PAL::PALError, /Interpolations are not supported in lookups/) + it 'returns the default value' do + result = run_cli_json(%w[lookup environment] + opts) + expect(result).to eq("environment data/common.yaml") end end From 4b9c2fa48987e672fa4f011f87babcb1458ecf81 Mon Sep 17 00:00:00 2001 From: alex501212 Date: Wed, 6 Nov 2024 12:14:25 +0000 Subject: [PATCH 5/7] remove puppet7 as test version in apply_spec --- spec/integration/apply_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/integration/apply_spec.rb b/spec/integration/apply_spec.rb index 1591179f4a..04a30c4f9c 100644 --- a/spec/integration/apply_spec.rb +++ b/spec/integration/apply_spec.rb @@ -9,7 +9,6 @@ require 'bolt_spec/run' TEST_VERSIONS = [ - [7, 'puppet7'], [8, 'puppet8'] ].freeze From 7d9ac15f4eb72d3d2dfd61d453e4697d9bf90871 Mon Sep 17 00:00:00 2001 From: alex501212 Date: Wed, 6 Nov 2024 12:14:56 +0000 Subject: [PATCH 6/7] remove some more ruby 2 tests --- .github/workflows/modules.yaml | 2 +- .github/workflows/windows.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/modules.yaml b/.github/workflows/modules.yaml index 1d59b51f71..e577473e35 100644 --- a/.github/workflows/modules.yaml +++ b/.github/workflows/modules.yaml @@ -39,7 +39,7 @@ jobs: runs-on: windows-latest strategy: matrix: - ruby: [2.7, 3.1] + ruby: [3.1] env: BOLT_WINDOWS: true steps: diff --git a/.github/workflows/windows.yaml b/.github/workflows/windows.yaml index c052f2194c..cc14a698cf 100644 --- a/.github/workflows/windows.yaml +++ b/.github/workflows/windows.yaml @@ -58,7 +58,7 @@ jobs: runs-on: windows-latest strategy: matrix: - ruby: [2.7, 3.1] + ruby: [3.1] env: BOLT_WINDOWS: true steps: From edf79d6817c68c2d7007cca96d65f420667dd237 Mon Sep 17 00:00:00 2001 From: alex501212 Date: Wed, 6 Nov 2024 16:31:08 +0000 Subject: [PATCH 7/7] updated docs --- documentation/hiera.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/documentation/hiera.md b/documentation/hiera.md index 85a2a33eb3..6cfc7582a0 100644 --- a/documentation/hiera.md +++ b/documentation/hiera.md @@ -162,13 +162,10 @@ Running the plan results in an error like this: ```shell $ bolt plan run my_project::request --targets server Starting: plan my_project::request -Finished: plan my_project::example in 0.01 sec -{ - "kind": "bolt/pal-error", - "msg": "Interpolations are not supported in lookups outside of an apply block: Undefined variable 'trusted' (file: /Users/bolt/.puppetlabs/bolt/hiera.yaml)", - "details": { - } -} +Interpolation failed with 'application', but compilation continuing; + (file & line not available) +Finished: plan my_project::request in 0.01 sec +Function lookup() did not find a value for the name 'api_key' ``` The plan run fails because the lookup takes place outside of an apply block, @@ -218,8 +215,9 @@ apply block. Interpolations are not well supported in the `plan_hierarchy` hierarchy. Target-level data such as facts are not available to lookups outside of apply blocks, -so the normal hierarchy interpolation does not work. The `lookup()` function -only interpolates based on the variables currently in scope. +so the normal hierarchy interpolation does not work. +However, the `lookup()` function can perform lookups without error by using default +values provided by Puppet and Hiera when the necessary context is not available. The following example demonstrates interpolating the `$application` variable into a `plan_hierarchy` hierarchy: