websoft9/apps/roles/role_common/tasks/tools_cockpit.yml

54 lines
1.2 KiB
YAML
Raw Normal View History

2022-07-11 14:03:55 +08:00
#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