-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_rpm_package.yml
43 lines (43 loc) · 2.01 KB
/
test_rpm_package.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
- hosts: all
user: root
tasks:
- name: show parameters coming from github
debug:
msg: "Request coming from github: |
actor: {{ github_actor | default('undefined') }}
repo: {{ github_repository | default('undefined') }}
workflow: {{ github_workflow | default('undefined') }} workspace: {{ github_workspace | default('undefined') }} event_name: {{ github_event_name | default('undefined') }} event_path: {{ github_event_path | default('undefined') }}
sha: {{ github_sha | default('undefined') }}
ref: {{ github_ref | default('undefined') }}
head_ref: {{ github_head_ref | default('undefined') }}
base_ref: {{ github_base_ref | default('undefined')}}
server_url: {{ github_server_url | default('undefined')}}
rpm_url: {{ github_rpm_url | default('undefined') }}
package_name: {{ github_package_name | default('scaphandre') }}
"
- fail:
msg: Server URL is not authorized to run this job.
when: github_server_url != "https://github.com"
- fail:
msg: Repository is not authorized to run this job.
when: not "scaphandre" in github_repository
- name: Ensure scaphandre package is purged
shell: "dnf remove -y {{ github_package_name | default('scaphandre') }}"
- name: Get RPM package
get_url:
url: "{{ github_rpm_url }}"
dest: .
register: download
- name: Install RPM package
shell: "dnf install -y {{ download.dest }}"
- name: Refresh systemd config
shell: systemctl daemon-reload
- name: Start & enable service
shell: "systemctl start {{ github_package_name | default('scaphandre')}} && systemctl enable {{ github_package_name | default('scaphandre')}}"
- name: Check service state
shell: "systemctl status {{ github_package_name | default('scaphandre') }}"
register: result
- name: Display error if failed
fail:
msg: "STDOUT: {{ result.stdout }} STDERR: {{ result.stderr }}"
when: result.rc != 0