This commit is contained in:
Hrankin, Aleksandr (contracted)
2026-02-19 11:34:13 +00:00
commit f243f440c3
191 changed files with 6183 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
---
- name: install base deps for HashiCorp repo
ansible.builtin.apt:
update_cache: true
name:
- ca-certificates # чтобы качать по HTTPS
- curl # чтобы скачать packer/плагины
- gnupg
- lsb-release
- unzip # packer часто в zip
state: present
- name: ensure keyrings dir exists
ansible.builtin.file:
path: /usr/share/keyrings
state: directory
mode: "0755"
- name: add HashiCorp GPG key (dearmored)
ansible.builtin.shell: |
set -euo pipefail
curl -fsSL https://apt.releases.hashicorp.com/gpg \
| gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
args:
executable: /bin/bash
creates: /usr/share/keyrings/hashicorp-archive-keyring.gpg
- name: add HashiCorp APT repository
ansible.builtin.copy:
dest: /etc/apt/sources.list.d/hashicorp.list
mode: "0644"
content: |
deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com {{ ansible_distribution_release }} main
- name: install packer
ansible.builtin.apt:
update_cache: true
name: packer
state: present
- name: check packer version
ansible.builtin.command: packer version
register: packer_version
changed_when: false
- name: print packer version
ansible.builtin.debug:
var: packer_version.stdout

View File

@@ -0,0 +1,33 @@
---
- name: ensure packer exists
ansible.builtin.command: packer version
changed_when: false
- name: packer init
ansible.builtin.command: packer init .
args:
chdir: "{{ packer_config_dir }}"
changed_when: false
- name: packer fmt
ansible.builtin.command: packer fmt -recursive .
args:
chdir: "{{ packer_config_dir }}"
changed_when: false
- name: packer validate
ansible.builtin.command: packer validate .
args:
chdir: "{{ packer_config_dir }}"
changed_when: false
- name: packer build
ansible.builtin.shell: |
set -euo pipefail
stdbuf -oL -eL packer build -on-error=cleanup -timestamp-ui .
args:
chdir: "{{ packer_config_dir }}"
executable: /bin/bash
environment:
PACKER_LOG: "1"
PACKER_LOG_PATH: ""