|
38 | 38 | ) |
39 | 39 | }} |
40 | 40 |
|
| 41 | +- name: Compute sanitized Cockpit plugin refs |
| 42 | + ansible.builtin.set_fact: |
| 43 | + terrarium_cockpit_zfs_ref_safe: "{{ terrarium_cockpit_zfs_ref | regex_replace('[^A-Za-z0-9._-]+', '-') }}" |
| 44 | + terrarium_cockpit_s3_ref_safe: "{{ terrarium_cockpit_s3_ref | regex_replace('[^A-Za-z0-9._-]+', '-') }}" |
| 45 | + |
| 46 | +- name: Compute versioned Cockpit plugin bundle filenames |
| 47 | + ansible.builtin.set_fact: |
| 48 | + terrarium_cockpit_zfs_bundle_filename: >- |
| 49 | + cockpit-plugin-zfs-{{ terrarium_cockpit_zfs_ref_safe }}-linux-{{ terrarium_cockpit_plugin_bundle_arch }}.tar.gz |
| 50 | + terrarium_cockpit_s3_bundle_filename: >- |
| 51 | + cockpit-plugin-s3-{{ terrarium_cockpit_s3_ref_safe }}-linux-{{ terrarium_cockpit_plugin_bundle_arch }}.tar.gz |
| 52 | +
|
41 | 53 | - name: Check cockpit-zfs install |
42 | 54 | ansible.builtin.stat: |
43 | 55 | path: /usr/share/cockpit/zfs/index.html |
|
48 | 60 | path: /usr/share/cockpit/cockpit-s3-browser/index.html |
49 | 61 | register: terrarium_cockpit_s3_installed |
50 | 62 |
|
51 | | -- name: Download prebuilt Cockpit plugin bundle |
| 63 | +- name: Download prebuilt cockpit-zfs bundle |
52 | 64 | ansible.builtin.get_url: |
53 | | - url: "https://github.com/{{ terrarium_cockpit_plugin_bundle_repo }}/releases/download/{{ terrarium_cockpit_plugin_bundle_ref }}/terrarium-cockpit-plugins-linux-{{ terrarium_cockpit_plugin_bundle_arch }}.tar.gz" |
54 | | - dest: "/tmp/terrarium-cockpit-plugins-{{ terrarium_cockpit_plugin_bundle_ref }}-{{ terrarium_cockpit_plugin_bundle_arch }}.tar.gz" |
| 65 | + url: "https://github.com/{{ terrarium_cockpit_plugin_bundle_repo }}/releases/download/{{ terrarium_cockpit_plugin_bundle_ref }}/{{ terrarium_cockpit_zfs_bundle_filename }}" |
| 66 | + dest: "/tmp/{{ terrarium_cockpit_plugin_bundle_ref }}-{{ terrarium_cockpit_zfs_bundle_filename }}" |
55 | 67 | mode: "0644" |
56 | | - register: terrarium_cockpit_plugin_bundle_download |
| 68 | + register: terrarium_cockpit_zfs_bundle_download |
57 | 69 | failed_when: false |
58 | 70 | when: |
59 | 71 | - terrarium_cockpit_plugin_bundle_enabled |
60 | 72 | - terrarium_cockpit_plugin_bundle_arch | length > 0 |
61 | 73 | - terrarium_cockpit_plugin_bundle_ref | length > 0 |
62 | 74 |
|
63 | | -- name: Determine whether prebuilt Cockpit plugin bundle is usable |
| 75 | +- name: Download prebuilt cockpit-s3 bundle |
| 76 | + ansible.builtin.get_url: |
| 77 | + url: "https://github.com/{{ terrarium_cockpit_plugin_bundle_repo }}/releases/download/{{ terrarium_cockpit_plugin_bundle_ref }}/{{ terrarium_cockpit_s3_bundle_filename }}" |
| 78 | + dest: "/tmp/{{ terrarium_cockpit_plugin_bundle_ref }}-{{ terrarium_cockpit_s3_bundle_filename }}" |
| 79 | + mode: "0644" |
| 80 | + register: terrarium_cockpit_s3_bundle_download |
| 81 | + failed_when: false |
| 82 | + when: |
| 83 | + - terrarium_cockpit_plugin_bundle_enabled |
| 84 | + - terrarium_cockpit_plugin_bundle_arch | length > 0 |
| 85 | + - terrarium_cockpit_plugin_bundle_ref | length > 0 |
| 86 | + |
| 87 | +- name: Determine whether prebuilt cockpit-zfs bundle is usable |
| 88 | + ansible.builtin.set_fact: |
| 89 | + terrarium_cockpit_zfs_bundle_usable: >- |
| 90 | + {{ |
| 91 | + terrarium_cockpit_zfs_bundle_download is defined |
| 92 | + and terrarium_cockpit_zfs_bundle_download is succeeded |
| 93 | + and terrarium_cockpit_zfs_bundle_download.dest is defined |
| 94 | + }} |
| 95 | +
|
| 96 | +- name: Determine whether prebuilt cockpit-s3 bundle is usable |
64 | 97 | ansible.builtin.set_fact: |
65 | | - terrarium_cockpit_plugin_bundle_usable: >- |
| 98 | + terrarium_cockpit_s3_bundle_usable: >- |
66 | 99 | {{ |
67 | | - terrarium_cockpit_plugin_bundle_download is defined |
68 | | - and terrarium_cockpit_plugin_bundle_download is succeeded |
69 | | - and terrarium_cockpit_plugin_bundle_download.dest is defined |
| 100 | + terrarium_cockpit_s3_bundle_download is defined |
| 101 | + and terrarium_cockpit_s3_bundle_download is succeeded |
| 102 | + and terrarium_cockpit_s3_bundle_download.dest is defined |
70 | 103 | }} |
71 | 104 |
|
72 | | -- name: Install prebuilt Cockpit plugin bundle |
| 105 | +- name: Install prebuilt cockpit-zfs bundle |
| 106 | + ansible.builtin.unarchive: |
| 107 | + src: "{{ terrarium_cockpit_zfs_bundle_download.dest }}" |
| 108 | + dest: / |
| 109 | + remote_src: true |
| 110 | + when: |
| 111 | + - terrarium_cockpit_zfs_bundle_usable | default(false) |
| 112 | + - terrarium_cockpit_zfs_bundle_download.changed or not terrarium_cockpit_zfs_installed.stat.exists |
| 113 | + |
| 114 | +- name: Install prebuilt cockpit-s3 bundle |
73 | 115 | ansible.builtin.unarchive: |
74 | | - src: "{{ terrarium_cockpit_plugin_bundle_download.dest }}" |
| 116 | + src: "{{ terrarium_cockpit_s3_bundle_download.dest }}" |
75 | 117 | dest: / |
76 | 118 | remote_src: true |
77 | 119 | when: |
78 | | - - terrarium_cockpit_plugin_bundle_usable | default(false) |
79 | | - - terrarium_cockpit_plugin_bundle_download.changed or not terrarium_cockpit_zfs_installed.stat.exists or not terrarium_cockpit_s3_installed.stat.exists |
| 120 | + - terrarium_cockpit_s3_bundle_usable | default(false) |
| 121 | + - terrarium_cockpit_s3_bundle_download.changed or not terrarium_cockpit_s3_installed.stat.exists |
80 | 122 |
|
81 | 123 | - name: Install cockpit plugin build dependencies |
82 | 124 | ansible.builtin.apt: |
83 | 125 | name: "{{ terrarium_cockpit_plugin_build_deps }}" |
84 | 126 | state: present |
85 | | - when: not (terrarium_cockpit_plugin_bundle_usable | default(false)) |
| 127 | + when: not (terrarium_cockpit_zfs_bundle_usable | default(false)) or not (terrarium_cockpit_s3_bundle_usable | default(false)) |
86 | 128 |
|
87 | 129 | - name: Enable corepack for yarn-managed builds |
88 | 130 | ansible.builtin.shell: | |
|
92 | 134 | args: |
93 | 135 | executable: /bin/bash |
94 | 136 | changed_when: false |
95 | | - when: not (terrarium_cockpit_plugin_bundle_usable | default(false)) |
| 137 | + when: not (terrarium_cockpit_zfs_bundle_usable | default(false)) or not (terrarium_cockpit_s3_bundle_usable | default(false)) |
96 | 138 |
|
97 | 139 | - name: Ensure plugin source directory exists |
98 | 140 | ansible.builtin.file: |
99 | 141 | path: /usr/local/src |
100 | 142 | state: directory |
101 | 143 | mode: "0755" |
102 | | - when: not (terrarium_cockpit_plugin_bundle_usable | default(false)) |
| 144 | + when: not (terrarium_cockpit_zfs_bundle_usable | default(false)) or not (terrarium_cockpit_s3_bundle_usable | default(false)) |
103 | 145 |
|
104 | 146 | - name: Checkout cockpit-zfs source |
105 | 147 | ansible.builtin.git: |
|
108 | 150 | version: "{{ terrarium_cockpit_zfs_ref }}" |
109 | 151 | force: true |
110 | 152 | register: terrarium_cockpit_zfs_checkout |
111 | | - when: not (terrarium_cockpit_plugin_bundle_usable | default(false)) |
| 153 | + when: not (terrarium_cockpit_zfs_bundle_usable | default(false)) |
112 | 154 |
|
113 | 155 | - name: Build and install cockpit-zfs |
114 | 156 | ansible.builtin.shell: | |
|
119 | 161 | chdir: /usr/local/src/cockpit-zfs |
120 | 162 | executable: /bin/bash |
121 | 163 | when: |
122 | | - - not (terrarium_cockpit_plugin_bundle_usable | default(false)) |
| 164 | + - not (terrarium_cockpit_zfs_bundle_usable | default(false)) |
123 | 165 | - terrarium_cockpit_zfs_checkout.changed or not terrarium_cockpit_zfs_installed.stat.exists |
124 | 166 |
|
125 | 167 | - name: Checkout cockpit-S3ObjectBroswer source |
|
129 | 171 | version: "{{ terrarium_cockpit_s3_ref }}" |
130 | 172 | force: true |
131 | 173 | register: terrarium_cockpit_s3_checkout |
132 | | - when: not (terrarium_cockpit_plugin_bundle_usable | default(false)) |
| 174 | + when: not (terrarium_cockpit_s3_bundle_usable | default(false)) |
133 | 175 |
|
134 | 176 | - name: Build and install cockpit-S3ObjectBroswer |
135 | 177 | ansible.builtin.shell: | |
|
140 | 182 | chdir: /usr/local/src/cockpit-S3ObjectBroswer |
141 | 183 | executable: /bin/bash |
142 | 184 | when: |
143 | | - - not (terrarium_cockpit_plugin_bundle_usable | default(false)) |
| 185 | + - not (terrarium_cockpit_s3_bundle_usable | default(false)) |
144 | 186 | - terrarium_cockpit_s3_checkout.changed or not terrarium_cockpit_s3_installed.stat.exists |
145 | 187 |
|
146 | 188 | - name: Restart cockpit socket after plugin install |
|
0 commit comments