Skip to content

Commit

Permalink
Merge pull request #5 from stuttgart-things/feature/issue-919-add-hom…
Browse files Browse the repository at this point in the history
…erun

added send to homerun task
  • Loading branch information
andre-ebert-sva authored Sep 6, 2024
2 parents 4aba9c3 + f4886bf commit f825261
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: Lint yaml files
uses: stuttgart-things/stuttgart-things/.github/workflows/lint-yaml.yaml@yaml-lint-1
with:
runs-on: ghr-create-send-webhook-labda-test
runs-on: ghr-create-send-webhook-skyami-cicd
environment-name: k8s
continue-error: true
yamllint-version: 1
Expand All @@ -29,7 +29,7 @@ jobs:
name: Lint ansible code
uses: stuttgart-things/stuttgart-things/.github/workflows/lint-ansible.yaml@main # ansible-lint-24.2.1
with:
runs-on: ghr-create-send-webhook-labda-test
runs-on: ghr-create-send-webhook-skyami-cicd
environment-name: k8s
continue-error: true
ansible-image: eu.gcr.io/stuttgart-things/sthings-ansible:9.3.0-1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ jobs:
release-message: "${{ github.event.inputs.release-message }}"
environment-name: k8s
archive-kind: tar.gz
runs-on: ghr-create-send-webhook-labda-test
runs-on: ghr-create-send-webhook-skyami-cicd
continue-error: false
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ EOF
ansible-playbook create-send-webhook.yaml -vv
```

```bash
ansible-playbook create-send-webhook.yaml -e send_to_homerun=true -vv
```

</details>


Expand Down
13 changes: 13 additions & 0 deletions defaults/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@
# defaults file for create-send-webhook
send_to_msteams: false
send_to_elastic: false
send_to_homerun: false
install_webhook_server: false

title: "Testnachricht"
message: "Das ist eine Testnachricht"
severity: "Info"
author: "Max Mustermann"
timestamp: "{{ ansible_date_time.date }} {{ ansible_date_time.hour }}:{{ ansible_date_time.minute }}:{{ ansible_date_time.second }}"

Check warning on line 12 in defaults/main.yaml

View workflow job for this annotation

GitHub Actions / Lint yaml files / Yaml-Lint

12:111 [line-length] line too long (132 > 110 characters)
system: "Testsystem"
technologyTags: "Test"
assigneeAddress: ""
assigneeName: "Max Mustermann"
artifacts: "https://www.google.com"
url: "https://www.google.com"

ignore_webhook_errors: false
logo_pic: "https://www.clipartmax.com/png/middle/120-1208387_cereal-guy-interested-by-rober-raik-cereal-guy-meme-png.png"

Check warning on line 21 in defaults/main.yaml

View workflow job for this annotation

GitHub Actions / Lint yaml files / Yaml-Lint

21:111 [line-length] line too long (121 > 110 characters)
failure_pic: "https://anthillonline.com/wp-content/uploads/2020/06/failure.png"
Expand Down
4 changes: 4 additions & 0 deletions tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
- name: Install webhook-server
ansible.builtin.include_tasks: install-webhook-server.yaml
when: install_webhook_server|bool

- name: Send notification to Homerun
ansible.builtin.include_tasks: send-to-homerun.yaml
when: send_to_homerun|bool
28 changes: 28 additions & 0 deletions tasks/send-to-homerun.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
- name: Sende Daten an die API
uri:
url: https://homerun.homerun-dev.sthings-vsphere.labul.sva.de/generic
method: POST
body: |
{
"Title": "{{ title }}",
"Info": "{{ message }}",
"Severity": "{{ severity }}",
"Author": "{{ author }}",
"Timestamp": "{{ timestamp }}",
"System": "{{ system }}",
"Tags": "{{ technologyTags }}",
"AssigneeAddress": "{{ assigneeAddress }}",
"AssigneeName": "{{ assigneeName }}",
"Artifacts": "{{ artifacts }}",
"Url": "{{ url }}"
}
body_format: json
headers:
Content-Type: "application/json"
X-Auth-Token: "IhrGeheimerToken"
status_code: 200
register: response

- name: Zeige Antwort
debug:
var: response

Check failure on line 28 in tasks/send-to-homerun.yaml

View workflow job for this annotation

GitHub Actions / Lint yaml files / Yaml-Lint

28:18 [new-line-at-end-of-file] no new line character at the end of file

0 comments on commit f825261

Please sign in to comment.