-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create hcloud_image_info snapshots on the fly
- Loading branch information
Showing
6 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
tests/integration/targets/hcloud_image_info/defaults/main/main.yml
This file contains 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,6 +1,6 @@ | ||
# Copyright: (c) 2019, Hetzner Cloud GmbH <[email protected]> | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
--- | ||
hcloud_snapshot_id: 10164049 | ||
hcloud_snapshot_name: always-there-snapshot | ||
hcloud_server_name: "{{ hcloud_ns }}" | ||
hcloud_snapshot_name: "{{ hcloud_ns }}" | ||
hcloud_image_name: ubuntu-22.04 |
This file contains 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
dependencies: | ||
- setup_hcloud_cli |
5 changes: 5 additions & 0 deletions
5
tests/integration/targets/hcloud_image_info/tasks/cleanup.yml
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- name: Cleanup test_server | ||
hetzner.hcloud.hcloud_server: | ||
name: "{{ hcloud_server_name }}" | ||
state: absent |
24 changes: 24 additions & 0 deletions
24
tests/integration/targets/hcloud_image_info/tasks/prepare.yml
This file contains 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
- name: Create test_server | ||
hetzner.hcloud.hcloud_server: | ||
name: "{{ hcloud_server_name }}" | ||
server_type: cx11 | ||
image: ubuntu-22.04 | ||
state: stopped | ||
register: test_server | ||
|
||
- name: Create test_snapshot | ||
ansible.builtin.script: | ||
cmd: > | ||
{{ hcloud_cli_path }} server create-image | ||
--type snapshot | ||
--description "{{ hcloud_snapshot_name }}" | ||
--label key=value | ||
"{{ test_server.hcloud_server.id }}" | ||
| awk '{print $2}' | ||
register: test_snapshot | ||
delegate_to: localhost | ||
|
||
- name: Set test_snapshot_id | ||
ansible.builtin.set_fact: | ||
test_snapshot_id: "{{ test_snapshot.stdout_lines[0] }}" |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
- name: Install hcloud cli | ||
delegate_to: localhost | ||
block: | ||
- name: Create temporary file for hcloud_cli_path | ||
ansible.builtin.tempfile: | ||
state: directory | ||
register: _tmp_hcloud_cli | ||
|
||
- name: Download hcloud cli from Github releases | ||
ansible.builtin.unarchive: | ||
src: https://github.com/hetznercloud/cli/releases/download/v1.37.0/hcloud-linux-amd64.tar.gz | ||
dest: "{{ _tmp_hcloud_cli.path }}" | ||
remote_src: true | ||
extra_opts: [hcloud] | ||
|
||
- name: Set hcloud_cli_path | ||
ansible.builtin.set_fact: | ||
hcloud_cli_path: "{{ _tmp_hcloud_cli.path }}/hcloud" |