-
Notifications
You must be signed in to change notification settings - Fork 0
feat(decdn_node): add manual local-binary install method #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,74 +1,116 @@ | ||
| --- | ||
| # Install the pinned decdn-node daemon + decdn CLI from GitHub Release tarballs. | ||
| # Idempotent and upgrade-aware via a version stamp; re-extracts only on change. | ||
| # NOTE: requires a published v<version> release (see role README). | ||
| # Install the decdn-node daemon + decdn CLI. Two methods, selected by | ||
| # decdn_node_install_method: | ||
| # "release" (default): download the pinned GitHub Release tarballs. Idempotent | ||
| # and upgrade-aware via a version stamp; re-extracts only on change. NOTE: | ||
| # requires a published v<version> release (see role README). | ||
| # "manual": copy locally-built binaries from the Ansible control machine (for | ||
| # pre-release / dev deploys). copy's checksum idempotency replaces the stamp. | ||
| # A --version backstop runs in both modes. | ||
|
|
||
| - name: Build the release tarball list | ||
| ansible.builtin.set_fact: | ||
| decdn_release_tarballs: | ||
| - {archive: decdn-node, sha: "{{ decdn_node_sha256 }}"} | ||
| - {archive: decdn, sha: "{{ decdn_cli_sha256 }}"} | ||
| - name: Install from pinned GitHub Release tarballs | ||
| when: decdn_node_install_method == "release" | ||
| block: | ||
| - name: Build the release tarball list | ||
| ansible.builtin.set_fact: | ||
| decdn_release_tarballs: | ||
| - {archive: decdn-node, sha: "{{ decdn_node_sha256 }}"} | ||
| - {archive: decdn, sha: "{{ decdn_cli_sha256 }}"} | ||
|
|
||
| - name: Read the installed-version stamp | ||
| ansible.builtin.slurp: | ||
| src: /usr/local/lib/decdn/installed-version | ||
| register: decdn_stamp | ||
| failed_when: false | ||
| changed_when: false | ||
| - name: Read the installed-version stamp | ||
| ansible.builtin.slurp: | ||
| src: /usr/local/lib/decdn/installed-version | ||
| register: decdn_stamp | ||
| failed_when: false | ||
| changed_when: false | ||
|
|
||
| - name: Decide whether (re)install is needed | ||
| ansible.builtin.set_fact: | ||
| decdn_need_install: >- | ||
| {{ (decdn_stamp.content is not defined) | ||
| or ((decdn_stamp.content | b64decode | trim) != decdn_node_version) }} | ||
| - name: Decide whether (re)install is needed | ||
| ansible.builtin.set_fact: | ||
| decdn_need_install: >- | ||
| {{ (decdn_stamp.content is not defined) | ||
| or ((decdn_stamp.content | b64decode | trim) != decdn_node_version) }} | ||
|
|
||
| - name: Install decdn-node + decdn CLI {{ decdn_node_version }} | ||
| when: decdn_need_install | ||
| block: | ||
| - name: Download release tarballs | ||
| ansible.builtin.get_url: | ||
| url: "{{ decdn_node_release_base }}/v{{ decdn_node_version }}/\ | ||
| {{ item.archive }}-{{ decdn_node_version }}-{{ decdn_node_target }}.tar.gz" | ||
| dest: "/tmp/{{ item.archive }}-{{ decdn_node_version }}.tar.gz" | ||
| mode: "0644" | ||
| checksum: "{{ ('sha256:' + item.sha) if (item.sha | length > 0) else omit }}" | ||
| loop: "{{ decdn_release_tarballs }}" | ||
| loop_control: | ||
| label: "{{ item.archive }}" | ||
| - name: Install decdn-node + decdn CLI {{ decdn_node_version }} | ||
| when: decdn_need_install | ||
| block: | ||
| - name: Download release tarballs | ||
| ansible.builtin.get_url: | ||
| url: "{{ decdn_node_release_base }}/v{{ decdn_node_version }}/\ | ||
| {{ item.archive }}-{{ decdn_node_version }}-{{ decdn_node_target }}.tar.gz" | ||
| dest: "/tmp/{{ item.archive }}-{{ decdn_node_version }}.tar.gz" | ||
| mode: "0644" | ||
| checksum: "{{ ('sha256:' + item.sha) if (item.sha | length > 0) else omit }}" | ||
| loop: "{{ decdn_release_tarballs }}" | ||
| loop_control: | ||
| label: "{{ item.archive }}" | ||
|
|
||
| - name: Extract binaries into /usr/local/bin | ||
| ansible.builtin.unarchive: | ||
| src: "/tmp/{{ item.archive }}-{{ decdn_node_version }}.tar.gz" | ||
| dest: /usr/local/bin | ||
| remote_src: true | ||
| - name: Extract binaries into /usr/local/bin | ||
| ansible.builtin.unarchive: | ||
| src: "/tmp/{{ item.archive }}-{{ decdn_node_version }}.tar.gz" | ||
| dest: /usr/local/bin | ||
| remote_src: true | ||
| owner: root | ||
| group: root | ||
| mode: "0755" | ||
| loop: "{{ decdn_release_tarballs }}" | ||
| loop_control: | ||
| label: "{{ item.archive }}" | ||
| notify: Restart decdn-node | ||
|
|
||
| - name: Ensure the stamp directory exists | ||
| ansible.builtin.file: | ||
| path: /usr/local/lib/decdn | ||
| state: directory | ||
| owner: root | ||
| group: root | ||
| mode: "0755" | ||
|
|
||
| - name: Record the installed version | ||
| ansible.builtin.copy: | ||
| dest: /usr/local/lib/decdn/installed-version | ||
| content: "{{ decdn_node_version }}\n" | ||
| owner: root | ||
| group: root | ||
| mode: "0644" | ||
|
|
||
| - name: Install locally-built binaries from the control machine | ||
| when: decdn_node_install_method == "manual" | ||
| block: | ||
| - name: Copy the decdn-node daemon + decdn CLI from the control machine | ||
| ansible.builtin.copy: | ||
| src: "{{ item.src }}" | ||
| dest: "{{ item.dest }}" | ||
| owner: root | ||
| group: root | ||
| mode: "0755" | ||
| loop: "{{ decdn_release_tarballs }}" | ||
| loop: | ||
| - {src: "{{ decdn_node_manual_bin_src }}", dest: "{{ decdn_bin }}"} | ||
| - {src: "{{ decdn_cli_manual_bin_src }}", dest: "{{ decdn_cli_bin }}"} | ||
| loop_control: | ||
| label: "{{ item.archive }}" | ||
| label: "{{ item.dest }}" | ||
| notify: Restart decdn-node | ||
|
|
||
| - name: Ensure the stamp directory exists | ||
| # Manual mode never reads the release version stamp, but a leftover stamp from | ||
| # a prior release deploy would make a later release re-deploy of the SAME | ||
| # version skip the download (decdn_need_install stays false). Clear it so a | ||
| # release <-> manual round-trip always re-fetches the official tarball. | ||
| - name: Clear the release version stamp in manual mode | ||
| ansible.builtin.file: | ||
| path: /usr/local/lib/decdn | ||
| state: directory | ||
| owner: root | ||
| group: root | ||
| mode: "0755" | ||
|
|
||
| - name: Record the installed version | ||
| ansible.builtin.copy: | ||
| dest: /usr/local/lib/decdn/installed-version | ||
| content: "{{ decdn_node_version }}\n" | ||
| owner: root | ||
| group: root | ||
| mode: "0644" | ||
| path: /usr/local/lib/decdn/installed-version | ||
| state: absent | ||
|
|
||
| # Integrity backstop: runs EVERY converge (not just on install), so a host whose | ||
| # binary drifted from the pin is caught loudly rather than trusted via the stamp. | ||
| - name: Verify the installed decdn-node reports the pinned version | ||
| # rc != 0 is included because a custom failed_when suppresses the module's default | ||
| # non-zero-exit check — else a broken manual binary (rc != 0) would pass silently. | ||
| # In "release" mode decdn_node_version is always set (asserted), so the version | ||
| # match is enforced; in "manual" mode with no version it degrades to a liveness | ||
| # check (rc == 0). | ||
| - name: Verify the installed decdn-node runs (version backstop) | ||
| ansible.builtin.command: "{{ decdn_bin }} --version" | ||
| register: decdn_installed_version | ||
| changed_when: false | ||
| failed_when: decdn_node_version not in decdn_installed_version.stdout | ||
| failed_when: >- | ||
| decdn_installed_version.rc != 0 | ||
| or (decdn_node_version | length > 0 | ||
| and decdn_node_version not in decdn_installed_version.stdout) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.