Files

37 lines
981 B
YAML

---
- name: Check if Syft is installed
ansible.builtin.command: syft version
register: sbom_syft_check
failed_when: false
changed_when: false
- name: Download Syft installer
ansible.builtin.get_url:
url: https://raw.githubusercontent.com/anchore/syft/main/install.sh
dest: /tmp/install-syft.sh
mode: "0755"
when: sbom_syft_check.rc != 0
- name: Install Syft
ansible.builtin.command:
cmd: /tmp/install-syft.sh -b /usr/local/bin
when: sbom_syft_check.rc != 0
changed_when: true
- name: Create report directory
ansible.builtin.file:
path: /opt/reports
state: directory
mode: "0755"
- name: Generate CycloneDX SBOM
ansible.builtin.command:
cmd: syft scan / -o cyclonedx-json=/opt/reports/sbom.json
changed_when: false
- name: Fetch SBOM
ansible.builtin.fetch:
src: /opt/reports/sbom.json
dest: "{{ playbook_dir }}/../reports/sbom/{{ inventory_hostname }}-{{ lookup('env', 'CI_PIPELINE_ID') }}.json"
flat: true