Files
kcare/roles/kernelcare/tasks/install_CentOS.yml
Gary Kwok ef6e10728d v1
2024-01-29 17:53:04 +08:00

72 lines
2.3 KiB
YAML

---
# tasks file for kernalcare
- block:
- name: Include site environment
include_vars: "{{ ansEnv }}.yml"
- include_tasks: housekeep_log.yml
- name: Remove packages if exists
ansible.builtin.yum:
name: "{{ item }}"
state: absent
loop:
- kernelcare
- pyOpenSSL
- name: Download the installation shell script
ansible.builtin.get_url:
url: "{{ eportal_srv }}/install-kernelcare"
dest: /tmp/kc-install.sh
mode: '0700'
validate_certs: false
register: kc_downloadresult
- block:
- name: Copy RPM files to target host
ansible.builtin.copy:
src: "{{ item }}"
dest: /root/
owner: root
group: root
mode: '0755'
loop:
- kernelcare-2.66-1.el7.x86_64.rpm
- pyOpenSSL-0.13.1-4.el7.x86_64.rpm
- name: "Customized the install script for offline install"
ansible.builtin.lineinfile:
dest: "/tmp/kc-install.sh"
regexp: "{{ item.regexp | default(omit) }}"
line: "{{ item.line }}"
insertafter: "{{ item.insertafter | default(omit) }}"
insertbefore: "{{ item.insertbefore | default(omit) }}"
state: "{{ item.state | default('present') }}"
loop:
- line: 'curl -s "$eportal_url/installer" | bash'
state: absent
- line: |
#curl -s "$eportal_url/installer" | bash
curl -L "$eportal_url/installer" -o /tmp/kc-installer.sh
sed -i 's/^PACKAGE_NAME=\${KCARE_PACKAGE_NAME:-\"kernelcare\"}/PACKAGE_NAME=\"\/root\/kernelcare-2.66-1.el7.x86_64.rpm \/root\/pyOpenSSL-0.13.1-4.el7.x86_64.rpm\"/g' /tmp/kc-installer.sh
bash /tmp/kc-installer.sh
insertbefore: "^echo \"Updating kernelcare repo...\""
when: downloadMode == "offline"
- name: Run the installation shell script
ansible.builtin.shell: /tmp/kc-install.sh
register: kc_execresult
- name: register KernelCare agents
ansible.builtin.shell: /usr/bin/kcarectl --register "{{ activation_key }}" --tag "{{ kernelcare_tagname }}"
when: kc_execresult.changed
notify:
- "Start KernelCare agent"
- "Disable libcare.socket"
- "Disable libcare.service"
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "7"