Skip to main content

Posts

Install KVM Hypervisor on CentOS 7.x and RHEL 7.x

KVM is an open source hardware virtualization software through which we can create and run multiple Linux based and windows based virtual machines simultaneously. KVM is known as Kernel based Virtual Machine because when we install KVM package then KVM module is loaded into the current kernel and turns our Linux machine into a hypervisor. In this post first we will demonstrate how we can install KVM hypervisor on CentOS 7.x and RHEL 7.x and then we will try to install virtual machines. Before proceeding KVM installation, let’s check whether your system’s CPU supports Hardware Virtualization. Run the beneath command from the console. [root@linuxtechi ~]# grep -E '(vmx|svm)' /proc/cpuinfo We should get the word either  vmx  or  svm  in the output, otherwise CPU doesn’t support virtualization. Step:1 Install KVM and its associate packages Run the following yum command to install KVM and its associated packages. [root@linuxtechi ~]# yum install qemu-kvm qemu-img virt-manager libvir...

Ansible cheat sheet

Configuration file intro_configuration.html First one found from of Contents of  $ANSIBLE_CONFIG ./ansible.cfg ~/.ansible.cfg /etc/ansible/ansible.cfg Configuration settings can be overridden by environment variables - see constants.py in the source tree for names. Patterns intro_patterns.html Used on the  ansible  command line, or in playbooks. all  (or  * ) hostname:  foo.example.com groupname:  webservers or:  webservers:dbserver exclude:  webserver:!phoenix intersection:  webservers:&staging Operators can be chained:  webservers:dbservers:&staging:!phoenix Patterns can include variable substitutions:  {{foo}} , wildcards:  *.example.com  or 192.168.1.*, and regular expressions:  ~(web|db).*\.example\.com Inventory files intro_inventory.html ,  intro_dynamic_inventory.html 'INI-file' structure, blocks define groups. Hosts allowed in more than one group. Non-standard SSH port can follow hostname separated by ':' (but see also  ansible_ssh_p...

Useful ansible stuff

inventory_hostname ‘ inventory_hostname ‘ contains the name of the current node being worked on…. (as in, what it is defined in your hosts file as) so if you want to skip a task for a single node – - name: Restart amavis service: name=amavis state=restarted when: inventory_hostname != "boris" (Don’t restart Amavis for boris,  do for all others). You could also use : ... when: inventory_hostname not in groups['group_name'] ... if your aim was to (perhaps skip) a task for some nodes in the specified group.   Need to check whether you need to reboot for a kernel update? If /vmlinuz doesn’t resolve to the same kernel as we’re running Reboot Wait 45 seconds before carrying on… - name: Check for reboot hint. shell: if [ $(readlink -f /vmlinuz) != /boot/vmlinuz-$(uname -r) ]; then echo 'reboot'; else echo 'no'; fi ignore_errors: true register: reboot_hint - name: Rebooting ... command: shutdown -r now "Ansible kernel update applied...

How to grep the output of cURL?

curl writes the output to stderr, so redirect that and also suppress the progress: curl - v -- silent https :// google . com / 2 >& 1 | grep expire The reason why  curl  writes the information to stderr is so you can do: curl <url> | someprgram  without that information clobbering the input of  someprogram It is possible to use  --stderr -  as parameter, to redirect the output from stderr (default) to stdout. With this option you also should use  --silent  to suppress the progress bar. $ curl - v -- silent https :// google . com / -- stderr - | grep expire * expire date : 2015 - 09 - 01 00 : 00 : 00 GMT  

Ansible issues

is not a valid attribute for a Play When ever you get the above error firstly crosscheck that the ansible attribute you have mentioned is correct. If it is correct then the issue probably is that you have created tasks as follows: --- - vars_prompt: - name: "var1" prompt: "Please pass variable" private: no - fail: msg="var1 is not passed or blank" when: var1 is undefined or ( var1 is defined and storeid == "" ) when it should be as follows: --- vars_prompt: - name: "var1" prompt: "Please pass variable" private: no tasks: - fail: msg="var1 is not passed or blank" when: var1 is undefined or ( var1 is defined and storeid == "" ) the example referenced is just a task. It is not a valid playbook because it is missings a hosts declaration and the module call is not under a tasks section. ERROR! conflicting action statements: fail, ...

Install Virtualbox on Centos 7

1. Change to root User Bash su - ## OR ## sudo -i 2. Install Fedora or RHEL Repo Files Bash cd /etc/yum.repos.d/ ## Fedora 26/25/24/23/22/21/20/19/18/17/16 users wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo ## CentOS 7.4/6.9 and Red Hat (RHEL) 7.4/6.9 users wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo 3. Update latest packages and check your kernel version Update packages Bash ## Fedora 26/25/24/23/22 ## dnf update ## Fedora 21/20/19/18/17/16 and CentOS/RHEL 7/6/5 ## yum update While executing yum update if you get any dependency errorfor glibc use the following to resolve it: rpm -qa | grep glibc You may see duplicates for either glibc or glibc common. There might be a common version in between any two packages of glibc and glibc-common. Remove the package which has uncommon version. You can also check for duplicates with the following command: yum list --showduplicates glibc rpm -e glibc-common-2.17-196.el7 rpm -qa kernel |...

PAE - Physical Address Extension

In  computing ,  Physical Address Extension  ( PAE ), sometimes referred to as  Page Address Extension ,  is a memory management feature for the x86 architecture. PAE was first introduced by Intel in the  Pentium Pro , and later by AMD in the  Athlon  processor.  It defines a  page table  hierarchy of three levels (instead of two), with table entries of 64 bits each instead of 32, allowing these CPUs to directly access a physical  address space  larger than 4  gigabytes  (2 32  bytes). The page table structure used by  x86-64  CPUs when operating in  long mode  further extends the page table hierarchy to four levels, extending the virtual address space, and uses additional physical address bits at all levels of the page table, extending the physical address space. It also uses the topmost bit of the 64-bit page table entry as a no-execute or  "NX" bit , indicating that code cannot be executed from the associated page. The NX feature is also available in  protected mode  when ...

cannot create directory : Permission denied

I had created a directory mkdir xyz with user centos The following is the output of ll command: drw-------. 2 centos centos 6 Oct 6 06:11 xyz When I executed cd xyz I received the following error: bash: cd: xyz/: Permission denied I could not access the directory in any case mkdir xyz/abc touch xyz/test.txt All returned the same error. The solution for this is to add +x permission on the directory. chmod 700 xyz/ Then I could cd into the directory and create files and folders. The logic behind this is as belows: Read bit  = If set, you can read this list. So, for example, if you have a directory named  poems : You can  ls poems  and you'll get a list of items living within ( -l  won't reveal any details!). You can use command-line completion i.e.  touch poems/so <TAB> poems/somefile . You cannot make  poems  your working directory (i.e.  cd  into it). Write bit  = If set, you can modify this list i.e. you can {add,rename,delete} names on it. But! You can actually...

Google sheets shortcut

Common actions Select column Ctrl + Space Select row Shift + Space Select all Ctrl + a Ctrl + Shift + Space Undo Ctrl + z Redo Ctrl + y Ctrl + Shift + z F4 Find Ctrl + f Find and replace Ctrl + h Fill range Ctrl + Enter Fill down Ctrl + d Fill right Ctrl + r Save (every change is saved automatically in Drive) Ctrl + s Open Ctrl + o Print Ctrl + p Copy Ctrl + c Cut Ctrl + x Paste Ctrl + v Paste values only Ctrl + Shift + v Show common keyboard shortcuts Ctrl + / Insert new sheet Shift + F11 Compact controls Ctrl + Shift + f Input tools on/off (available in spreadsheets in non-Latin languages) Ctrl + Shift + k Select input tools Ctrl + Alt + Shift + k Format cells Bold Ctrl + b Underline Ctrl + u Italic Ctrl + i Strikethrough Alt + Shift + 5 Center align Ctrl + Shift + e Left align Ctrl + Shift + l Right align Ctrl + Shift + r Apply top border Alt + Shift + 1 Apply right border Alt + Shift + 2 Apply bottom border Alt + Shift + 3 Apply left border Alt + Shift + 4 Remove borders Alt + Shif...

Saltstack and Vault integration

First install and configure vault using this tutorial: https://apassionatechie.wordpress.com/2017/03/05/hashicorp-vault/ Use the latest version of vault. Then install salt using the steps given here: https://docs.saltstack.com/en/latest/topics/installation/ If you face any issues then refer these links: https://apassionatechie.wordpress.com/2017/07/31/salt-issues/ https://apassionatechie.wordpress.com/2017/08/03/salt-stack-formulas/ Now let's integrate vault and salt so that we can access vault secrets from inside salt state. First let's add some key values into our vault. vault write secret/ssh/user1 password="abc123" Then you can check it by reading: vault read secret/ssh/user1 To allow salt to access your secrets you must firstly create a policy as follows: salt-policy.hcl [code] path "secret/*" { capabilities = ["read", "list"] } path "auth/*" { capabilities = ["read", "list","sudo",...

Hashicorp Consul Installation on Centos 7

Consul must first be installed on your machine. Consul is distributed as a  binary package  for all supported platforms and architectures. This page will not cover how to compile Consul from source, but compiling from source is covered in the  documentation  for those who want to be sure they're compiling source they trust into the final binary. Installing Consul To install Consul, find the  appropriate package  for your system and download it. Consul is packaged as a zip archive. After downloading Consul, unzip the package. Consul runs as a single binary named  consul . Any other files in the package can be safely removed and Consul will still function. The final step is to make sure that the  consul  binary is available on the  PATH . See  this page  for instructions on setting the PATH on Linux and Mac.  This page  contains instructions for setting the PATH on Windows. Verifying the Installation After installing Consul, verify the installation worked by opening a new terminal se...

Chef: Overview

Chef is a powerful automation platform that transforms infrastructure into code. Whether you’re operating in the cloud, on-premises, or in a hybrid environment, Chef automates how infrastructure is configured, deployed, and managed across your network, no matter its size. This diagram shows how you develop, test, and deploy your Chef code. The workstation is the location from which users interact with Chef. On the workstation users author and test  cookbooks  using tools such as  Test Kitchen  and interact with the Chef server using the  knife  and  chef command line tools. Nodes are the machines—physical, virtual, cloud, and so on—that are under management by Chef. The chef-client is installed on each node and is what  performs the automation on that machine . Use the Chef server as your foundation to create and manage flexible, dynamic infrastructure whether you manage 50 or 500,000 nodes, across multiple datacenters, public and private clouds, and in heterogeneous environments...