Patch Management : Linux
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ANSIBLE PATCH MANAGEMENT
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Generally on enterprise setup you have got satellite , - Configuration management tool
Lets assume you do not have any of these tools and you have a bug for which you need to apply Kernel patch on 1000 servers .
ignore_error : this will ignore error and will not exit out
register : app_process_check (this becomes the various which will register the output of shell module )
Second task
inventory_host name : the host where the command is getting run
it checks for the condition is the output from the variable app_process_check.stdout == "process_running" the patching will fail if the application is running . it will quite the patching job but will display the message while quitting .
We are using Yum package manager where our clients are on red-hat or CentOS 7 .
If you want to update all package you can replace "kernel" with a "*" this will update all package
Name = "kernel" -- all packages of kernel gets updated.
state = latest -- means they will get the latest updates.
when : state when the upgrade or installation must happen places the condition
some examples of ansible_distribution
tasks: - name: "shut down CentOS 6 and Debian 7 systems" command: /sbin/shutdown -t now when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "6") or (ansible_distribution == "Debian" and ansible_distribution_major_version == "7")
https://docs.ansible.com/ansible/2.6/user_guide/playbooks_conditionals.html
register : yum_update -- we are registering the update of yum_update variable
Next Task
checking if Kernel update has happend or it needs reboot
This will check what is the new kernel that got installed on the system
Installing Kernel Packages - example
| yum: name={{ item }} state=present |
| with_items: |
| - ncurses-devel |
| - bc |
| - openssl-devel |
| - hmaccalc |
| - zlib-devel |
| - binutils-devel |
| - name: install kernel dev packages |
This task will check if the kernel update has happens , if so it goes for a reboot, else it does not reboot.
Check the ansible_distribution
$ ansible -m setup all | grep ansible_distribution
Comments
Post a Comment