v1
This commit is contained in:
7
deploy_kernelcare.yml
Normal file
7
deploy_kernelcare.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- hosts: "{{ inputHostsGroups }}"
|
||||||
|
gather_facts: false
|
||||||
|
become: yes
|
||||||
|
roles:
|
||||||
|
- kernelcare
|
||||||
8
hello.yml
Normal file
8
hello.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- name: This is a hello-world example
|
||||||
|
hosts: "{{ inputHosts }}"
|
||||||
|
tasks:
|
||||||
|
- name: Create a file called '/tmp/testfile.txt' with the content 'hello world'.
|
||||||
|
copy:
|
||||||
|
content: hello world
|
||||||
|
dest: /tmp/testfile.txt
|
||||||
13
kernelcare_agent_uninstall.yml
Normal file
13
kernelcare_agent_uninstall.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
- hosts: "{{ inputHosts }}"
|
||||||
|
become: yes
|
||||||
|
tasks:
|
||||||
|
- name: unregister KernelCare agents
|
||||||
|
command: /usr/bin/kcarectl --unregister
|
||||||
|
ignore_errors: yes
|
||||||
|
args:
|
||||||
|
removes: /usr/bin/kcarectl
|
||||||
|
|
||||||
|
- name: remove kernelcare package
|
||||||
|
package:
|
||||||
|
name: kernelcare
|
||||||
|
state: absent
|
||||||
26
kernelcare_dev_agent_install.yml
Normal file
26
kernelcare_dev_agent_install.yml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
- hosts: "{{ inputHosts }}"
|
||||||
|
become: yes
|
||||||
|
vars:
|
||||||
|
eportal_srv: "{{ eportal_srv }}"
|
||||||
|
activation_key: "{{ activation_key }}"
|
||||||
|
tasks:
|
||||||
|
- name: Download the installation shell script
|
||||||
|
get_url:
|
||||||
|
url: "{{ eportal_srv }}/install-kernelcare"
|
||||||
|
dest: /tmp/kc-install.sh
|
||||||
|
mode: '0700'
|
||||||
|
|
||||||
|
- name: Run the installation shell script
|
||||||
|
command: /tmp/kc-install.sh
|
||||||
|
|
||||||
|
- name: register KernelCare agents
|
||||||
|
command: /usr/bin/kcarectl --register {{ activation_key }}
|
||||||
|
|
||||||
|
- name: tagging
|
||||||
|
command: /usr/bin/kcarectl --tag "product:scc;env:dev"
|
||||||
|
|
||||||
|
# - name: Start and enable kcare
|
||||||
|
# service:
|
||||||
|
# name: kcare
|
||||||
|
# state: started
|
||||||
|
# enabled: yes
|
||||||
38
roles/kernelcare/README.md
Normal file
38
roles/kernelcare/README.md
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
Role Name
|
||||||
|
=========
|
||||||
|
|
||||||
|
A brief description of the role goes here.
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
|
||||||
|
|
||||||
|
Role Variables
|
||||||
|
--------------
|
||||||
|
|
||||||
|
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
|
||||||
|
|
||||||
|
Example Playbook
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
|
||||||
|
|
||||||
|
- hosts: servers
|
||||||
|
roles:
|
||||||
|
- { role: username.rolename, x: 42 }
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
BSD
|
||||||
|
|
||||||
|
Author Information
|
||||||
|
------------------
|
||||||
|
|
||||||
|
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
|
||||||
15
roles/kernelcare/defaults/main.yml
Normal file
15
roles/kernelcare/defaults/main.yml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
# defaults file for kcare
|
||||||
|
|
||||||
|
# Gather facts fliter (for faster)
|
||||||
|
# Only use needed facts
|
||||||
|
gfacts_fliter:
|
||||||
|
- "!all"
|
||||||
|
- distribution
|
||||||
|
- distribution_major_version
|
||||||
|
- distribution_release
|
||||||
|
- distribution_version
|
||||||
|
- os_family
|
||||||
|
- pkg_mgr
|
||||||
|
- python
|
||||||
|
- python_version
|
||||||
BIN
roles/kernelcare/files/kernelcare-2.66-1.el7.x86_64.rpm
Normal file
BIN
roles/kernelcare/files/kernelcare-2.66-1.el7.x86_64.rpm
Normal file
Binary file not shown.
BIN
roles/kernelcare/files/pyOpenSSL-0.13.1-4.el7.x86_64.rpm
Normal file
BIN
roles/kernelcare/files/pyOpenSSL-0.13.1-4.el7.x86_64.rpm
Normal file
Binary file not shown.
25
roles/kernelcare/handlers/main.yml
Normal file
25
roles/kernelcare/handlers/main.yml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
# handlers file for kernelcare
|
||||||
|
|
||||||
|
- name: "Start KernelCare agent"
|
||||||
|
service:
|
||||||
|
name: kcare
|
||||||
|
state: started
|
||||||
|
enabled: yes
|
||||||
|
|
||||||
|
- name: "Restart KernelCare agent"
|
||||||
|
service:
|
||||||
|
name: kcare
|
||||||
|
state: restarted
|
||||||
|
|
||||||
|
- name: "Disable libcare.socket"
|
||||||
|
service:
|
||||||
|
name: libcare.socket
|
||||||
|
state: stopped
|
||||||
|
enabled: no
|
||||||
|
|
||||||
|
- name: "Disable libcare.service"
|
||||||
|
service:
|
||||||
|
name: libcare.service
|
||||||
|
state: stopped
|
||||||
|
enabled: no
|
||||||
53
roles/kernelcare/meta/main.yml
Normal file
53
roles/kernelcare/meta/main.yml
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
galaxy_info:
|
||||||
|
author: your name
|
||||||
|
description: your role description
|
||||||
|
company: your company (optional)
|
||||||
|
|
||||||
|
# If the issue tracker for your role is not on github, uncomment the
|
||||||
|
# next line and provide a value
|
||||||
|
# issue_tracker_url: http://example.com/issue/tracker
|
||||||
|
|
||||||
|
# Choose a valid license ID from https://spdx.org - some suggested licenses:
|
||||||
|
# - BSD-3-Clause (default)
|
||||||
|
# - MIT
|
||||||
|
# - GPL-2.0-or-later
|
||||||
|
# - GPL-3.0-only
|
||||||
|
# - Apache-2.0
|
||||||
|
# - CC-BY-4.0
|
||||||
|
license: license (GPL-2.0-or-later, MIT, etc)
|
||||||
|
|
||||||
|
min_ansible_version: 2.9
|
||||||
|
|
||||||
|
# If this a Container Enabled role, provide the minimum Ansible Container version.
|
||||||
|
# min_ansible_container_version:
|
||||||
|
|
||||||
|
#
|
||||||
|
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||||
|
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||||
|
# To view available platforms and versions (or releases), visit:
|
||||||
|
# https://galaxy.ansible.com/api/v1/platforms/
|
||||||
|
#
|
||||||
|
# platforms:
|
||||||
|
# - name: Fedora
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 25
|
||||||
|
# - name: SomePlatform
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 1.0
|
||||||
|
# - 7
|
||||||
|
# - 99.99
|
||||||
|
|
||||||
|
galaxy_tags: []
|
||||||
|
# List tags for your role here, one per line. A tag is a keyword that describes
|
||||||
|
# and categorizes the role. Users find roles by searching for tags. Be sure to
|
||||||
|
# remove the '[]' above, if you add tags to this list.
|
||||||
|
#
|
||||||
|
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
|
||||||
|
# Maximum 20 tags per role.
|
||||||
|
|
||||||
|
dependencies: []
|
||||||
|
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||||
|
# if you add dependencies to this list.
|
||||||
|
|
||||||
10
roles/kernelcare/tasks/housekeep_log.yml
Normal file
10
roles/kernelcare/tasks/housekeep_log.yml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
# tasks file for kernalcare
|
||||||
|
|
||||||
|
- name: Housekeeping kcare log file or directory
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
loop:
|
||||||
|
- /var/log/kcarectl.log
|
||||||
|
- /var/log/libcare
|
||||||
71
roles/kernelcare/tasks/install_CentOS.yml
Normal file
71
roles/kernelcare/tasks/install_CentOS.yml
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
---
|
||||||
|
# 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"
|
||||||
21
roles/kernelcare/tasks/main.yml
Normal file
21
roles/kernelcare/tasks/main.yml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
# tasks file for kernalcare
|
||||||
|
|
||||||
|
- name: Gather facts
|
||||||
|
ansible.builtin.setup:
|
||||||
|
gather_subset: "{{ gfacts_fliter }}"
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: "Trigger install task if selected option is install"
|
||||||
|
include_tasks: install_CentOS.yml
|
||||||
|
when: ansOption == "install"
|
||||||
|
|
||||||
|
- name: "Trigger uninstall task if selected option is uninstall"
|
||||||
|
include_tasks: uninstall_CentOS.yml
|
||||||
|
when: ansOption == "uninstall"
|
||||||
|
|
||||||
|
- name: "Trigger update HTTPS task if selected option is update_https"
|
||||||
|
include_tasks: updateHTTPS_CentOS.yml
|
||||||
|
when: ansOption == "update_https"
|
||||||
|
|
||||||
|
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "7"
|
||||||
20
roles/kernelcare/tasks/uninstall_CentOS.yml
Normal file
20
roles/kernelcare/tasks/uninstall_CentOS.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
# tasks file for kernalcare
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: unregister KernelCare agents
|
||||||
|
ansible.builtin.command: /usr/bin/kcarectl --unregister
|
||||||
|
ignore_errors: yes
|
||||||
|
args:
|
||||||
|
removes: /usr/bin/kcarectl
|
||||||
|
|
||||||
|
- name: remove kernelcare package
|
||||||
|
ansible.builtin.package:
|
||||||
|
name:
|
||||||
|
- kernelcare
|
||||||
|
- libcare
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- include_tasks: housekeep_log.yml
|
||||||
|
|
||||||
|
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "7"
|
||||||
43
roles/kernelcare/tasks/updateHTTPS_CentOS.yml
Normal file
43
roles/kernelcare/tasks/updateHTTPS_CentOS.yml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
---
|
||||||
|
# tasks file for kernalcare
|
||||||
|
# Update from HTTP to HTTPS
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: "Check /etc/sysconfig/kcare/kcare.conf if exists"
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "/etc/sysconfig/kcare/kcare.conf"
|
||||||
|
register: result_config
|
||||||
|
|
||||||
|
- name: "Update to HTTPS in /etc/sysconfig/kcare/kcare.conf"
|
||||||
|
ansible.builtin.replace:
|
||||||
|
path: "/etc/sysconfig/kcare/kcare.conf"
|
||||||
|
regexp: "{{ item.regexp | default(omit) }}"
|
||||||
|
replace: "{{ item.replace | default(omit) }}"
|
||||||
|
loop:
|
||||||
|
- regexp: "^PATCH_SERVER=http"
|
||||||
|
replace: "PATCH_SERVER=https"
|
||||||
|
- regexp: "^REGISTRATION_URL=http"
|
||||||
|
replace: "REGISTRATION_URL=https"
|
||||||
|
notify:
|
||||||
|
- "Restart KernelCare agent"
|
||||||
|
when: result_config.stat.exists
|
||||||
|
|
||||||
|
|
||||||
|
- name: "Check /etc/yum.repos.d/kernelcare.repo if exists"
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "/etc/yum.repos.d/kernelcare.repo"
|
||||||
|
register: result_yumrepo
|
||||||
|
|
||||||
|
- name: "Update to HTTPS in /etc/yum.repos.d/kernelcare.repo"
|
||||||
|
ansible.builtin.replace:
|
||||||
|
path: "/etc/yum.repos.d/kernelcare.repo"
|
||||||
|
regexp: "{{ item.regexp | default(omit) }}"
|
||||||
|
replace: "{{ item.replace | default(omit) }}"
|
||||||
|
loop:
|
||||||
|
- regexp: "^baseurl=http"
|
||||||
|
replace: "baseurl=https"
|
||||||
|
- regexp: "^gpgkey=http"
|
||||||
|
replace: "gpgkey=https"
|
||||||
|
when: result_yumrepo.stat.exists
|
||||||
|
|
||||||
|
when: ansible_distribution == "CentOS" and ansible_distribution_major_version == "7"
|
||||||
18
roles/kernelcare/templates/kc-install.j2
Normal file
18
roles/kernelcare/templates/kc-install.j2
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e -o pipefail
|
||||||
|
eportal_url="{{ eportal_srv }}"
|
||||||
|
|
||||||
|
hash curl
|
||||||
|
|
||||||
|
export KCARE_REPO="$eportal_url/repo"
|
||||||
|
export KCARE_PATCH_SERVER="$eportal_url"
|
||||||
|
export KCARE_REGISTRATION_URL="$eportal_url/admin/api/kcare"
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
echo "Updating kernelcare repo..."
|
||||||
|
curl -s "$eportal_url/set-kernelcare-repo" | bash
|
||||||
|
echo "Done."
|
||||||
2
roles/kernelcare/tests/inventory
Normal file
2
roles/kernelcare/tests/inventory
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
||||||
5
roles/kernelcare/tests/test.yml
Normal file
5
roles/kernelcare/tests/test.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- trunk
|
||||||
7
roles/kernelcare/vars/hk_prd.yml
Normal file
7
roles/kernelcare/vars/hk_prd.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
# vars file for Hong Kong UAT
|
||||||
|
|
||||||
|
eportal_srv: "http://kcareprd.ecvision.com"
|
||||||
|
activation_key: "arprdkcarekey-scc"
|
||||||
|
kernelcare_tagname: "product:scc;env:prd"
|
||||||
|
|
||||||
7
roles/kernelcare/vars/hk_uat.yml
Normal file
7
roles/kernelcare/vars/hk_uat.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
# vars file for Hong Kong UAT
|
||||||
|
|
||||||
|
eportal_srv: "http://kcareuat.ecvision.com"
|
||||||
|
activation_key: "aruatkcarekey-scc"
|
||||||
|
kernelcare_tagname: "product:scc;env:uat"
|
||||||
|
|
||||||
2
roles/kernelcare/vars/main.yml
Normal file
2
roles/kernelcare/vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for trunk
|
||||||
6
roles/kernelcare/vars/office_dev.yml
Normal file
6
roles/kernelcare/vars/office_dev.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
# vars file for HK Office
|
||||||
|
|
||||||
|
eportal_srv: "http://kcaredev.ecvision.com"
|
||||||
|
activation_key: "ardevkcarekey-scc"
|
||||||
|
kernelcare_tagname: "product:scc;env:dev"
|
||||||
6
roles/kernelcare/vars/svl_stg.yml
Normal file
6
roles/kernelcare/vars/svl_stg.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
# vars file for Sunnyvale Staging (usdc4uat)
|
||||||
|
|
||||||
|
eportal_srv: "http://10.204.2.107"
|
||||||
|
activation_key: "aruatkcarekey-scc"
|
||||||
|
kernelcare_tagname: "product:scc;env:uat"
|
||||||
6
roles/kernelcare/vars/svl_uat.yml
Normal file
6
roles/kernelcare/vars/svl_uat.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
# vars file for Sunnyvale UAT (usdc1uat)
|
||||||
|
|
||||||
|
eportal_srv: "http://10.204.2.107"
|
||||||
|
activation_key: "aruatkcarekey-scc"
|
||||||
|
kernelcare_tagname: "product:scc;env:uat"
|
||||||
Reference in New Issue
Block a user