mirror of
https://github.com/Websoft9/websoft9.git
synced 2025-01-24 18:30:23 +08:00
54 lines
1.2 KiB
YAML
54 lines
1.2 KiB
YAML
|
#1 Prepare
|
||
|
- set_fact:
|
||
|
common_cockpit_port: "9099"
|
||
|
|
||
|
#2 Install cockpit
|
||
|
- name: Install cockpit
|
||
|
apt:
|
||
|
name: [cockpit*]
|
||
|
update_cache: yes
|
||
|
when: ansible_os_family == "Debian"
|
||
|
|
||
|
- name: Install cockpit
|
||
|
yum:
|
||
|
name: [cockpit*]
|
||
|
update_cache: yes
|
||
|
when: ansible_os_family == "RedHat"
|
||
|
|
||
|
|
||
|
#3 Configure
|
||
|
- name: Change cockpit port
|
||
|
lineinfile:
|
||
|
dest: /lib/systemd/system/cockpit.socket
|
||
|
regexp: "ListenStream=9090"
|
||
|
line: "ListenStream={{common_cockpit_port}}"
|
||
|
backrefs: yes
|
||
|
|
||
|
- name: Create /etc/cockpit/cockpit.conf
|
||
|
file:
|
||
|
path: /etc/cockpit/cockpit.conf
|
||
|
owner: cockpit-ws
|
||
|
group: cockpit-ws
|
||
|
mode: '0640'
|
||
|
state: touch
|
||
|
|
||
|
- name: Insert configuration items in cockpit.conf
|
||
|
blockinfile:
|
||
|
path: /etc/cockpit/cockpit.conf
|
||
|
block: |
|
||
|
# allow http connection, Otherwise, it redirects all HTTP connections to HTTPS
|
||
|
[WebService]
|
||
|
AllowUnencrypted = true
|
||
|
- name: Start & Enable cockpit
|
||
|
shell: |
|
||
|
systemctl restart cockpit
|
||
|
systemctl daemon-reload
|
||
|
systemctl restart cockpit.socket
|
||
|
systemctl enable --now cockpit.socket
|
||
|
|
||
|
#4 Check
|
||
|
- name: Check cockpit Service
|
||
|
shell: systemctl status cockpit | grep Active*
|
||
|
register: check_cockpit_service
|
||
|
notify: check_cockpit_service
|