Skip to main content

Posts

call to function "map" failed: the "map" function was deprecated in Terrafrom

How to change map method to tomap method? Let's say you have multiple tags in your code which was written quite back and that time it was working fine on old Terraform version before v0.12 but if the same code you execute on updated/latest Terrafrom you get subjected error while try to run Terrafrom plan command. Then this article will help you to fix your issue. What is simple solution to fix this issue? Just replace " map " method to " tomap " and just to little bit formatting for the same. Syntax:- map ({"Name", "My_Name"), map("AppName", "My_App")}) tomap ({"Name"  =   "My_Name",  "App_Name"  =   "My_App"}) or tomap ({     "Name"  =   "My_Name",     "App_Name"  =   "My_App" }) #Code with " map " method resource "aws_instance" "My_instance"   ami   =   my_ami   instance_type =   my_type   tags  =   merge(var.tag

error: src refspec main does not match any

$ git push -u origin main error: src refspec main does not match any error: failed to push some refs to 'https://gitlab.com/jay2tinku/my-new-project.git' If you get such error while performing any git operation. This means you have to check your default branch name. From last few git versions by default branch name is main instead of master . It never means that it will always be main/master . Normally at the time of installation we have to configure that but most of the time we ignore that and go with default options. Simple fix of this error is :- git push -u origin master or git push -u origin main Please have a look on below scenario for complete understanding $ mkdir my-new-project $ cd  my-new-project $ git status $ git init $ cat > test.txt My first line!!! $  git status $ git remote add origin https://gitlab.com/jay2tinku/my-test-project.git $ git add . $ git status $ git commit . -m "Intial push commit" $ git push -u origin main error: src refspec main do

Mouse is not working in VirtualBox VM(Install guest addition on RHEL8/CentOS8)

If you are unable to move mouse curser on full screen in your VirtualBox vm, this is the correct article to fix this issue. To fix this issue we need to install  gcc, make, perl, kernel-devel and  elfutils-libelf-devel  packages and after that guest addition has to be installed. I am considering that yum is configured on your system. So lets start with installation of packages. Step1: - Install mentioned packages using dnf/yum [root@localhost ~]# yum install gcc make perl -y [root@localhost ~]# yum install kernel-devel -y [root@localhost ~]# yum install elfutils-libelf-devel -y Step2: -  Insert Guest Additions CD image... Step3: - Check if Guest Additions mounted  [root@localhost ~]# df -hT |grep VBox /dev/sr0              iso9660    58M   58M     0 100% /run/media/root/VBox_GAs_6.1.12 [root@localhost ~]# cd /run/media/root/VBox_GAs_6.1.12 [root@localhost VBox_GAs_6.1.12]# ll VBoxLinuxAdditions.run -r-xr-xr-x. 1 root root 7351732 Jul 11 02:45 VBoxLinuxAdditions.run [root@localhost VBo

Please add this host's fingerprint to your known_hosts file to manage this host

Error: - 192.168.43.216 | FAILED! => {     "msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this.  Please add this host's fingerprint to your known_hosts file to manage this host." }  If you get above error message on Ansible controller that means your managed host are not added to known hosts. You can fix this issue in two way: - 1. Add " host_key_checking = false " in ansible.cfg( best practice ) [root@ansible ssh]# cat >> /etc/ansible/ansible.cfg host_key_checking = false Let's check if issue has been fixed, If I am getting "ping": "pong" response that mean the issue has been fixed. [root@ansible ssh]# ansible all -m ping 192.168.43.72 | SUCCESS => {     "ansible_facts": {         "discovered_interpreter_python": "/usr/libexec/platform-python"     },     "changed": false,     "ping": &qu

Ansible ad-hoc commands and playbook

In previous post we have understood the usage and basics of Ansible. Also we have have installed Ansible on RHEL8 and setup our Lab environment so that we can practice. Now this is time to move ahead and learn more about Ansible and see how we can use an intelligent configuration management automation tool in our environment. There are two types of automation approaches we can adopt in our environment for configuration management: - 1. Traditional Automation: - Automation using scripts which can be written in any scripting language (Shell, Perl, Python etc.). In this approach as per requirement we write a script and whenever we run this script it do the needful. This kind of automation works fine until there is any change in environment. But as we know this is not possible, our environment keep on changes and slight change may fail our automation completely. How? Example: - Configure httpd on RHEL6 , below are the simple commands we use to configure httpd in RHEL6. Which we can put

Introduction to Ansible

Introduction to Ansible :- Ansible is a very intelligent and powerful tool in terms of Configuration management. In very simple language we can say that it is a  configuration management automation tool.  Apart from that it has capability to do multiple of things in IT world like  software provisioning  and  application-deployment tool enabling infrastructure as code . In terms on platform support, so it can be run on UNIX/Linux system and can configure UNIX/Linux and Windows both kind of operating systems.  From today onward I'll start posting each and everything about Ansible, so you can start an technical journey which will help you to learn Ansible tool from zero to advance level. Since it is very first day so we will try to setup our lab environment and also try to do a simple configuration on a remote host.  I have two RHEL8( Red Hat Enterprise Linux 8 ) virtual machine installed on Oracle VirtualBox machines. The host on which we install Ansible is know as Ansible co

AWS cloud automation using Terraform

In this post I'll create multiple resources in AWS cloud using Terraform . Terraform is an infrastructure as code( IAC ) software which can do lots of things but it is superb in cloud automation. To use Terraform we have write code in a high-level configuration language known as Hashicorp Configuration Language , optionally we can write code in JSON as well. I'll create below service using Terraform- 1. Create the key-pair and security group which allow inbound traffic on port 80 and 22 2. Launch EC2 instance. 3. To create EC2 instance use same key and security group which created in step 1 4. Launch Volume(EBS) and mount this volume into /var/www/html directory 5. Upload index.php file and an image on GitHub repository 6. Clone GitHub repository into /var/www/html 7. Create S3 bucket, copy images from GitHub repo into it and set permission to public readable 8 Create a CloudFront use S3 bucket(which contains images) and use the CloudFront URL to update code in /var/w

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? Root cause of this error message is only that DOCKER_HOST variable has not been exported to all the users. In my case it was working fine while I was running docker commands as root user but when I tried the same commands from Jenkins, didn't work. To understand this issue in detail let me create such environment and see troubleshooting steps. Docker Host - [root@server106 ~]# hostname server106.example.com Docker Client - [root@server109 ~]# hostname server109.example.com [root@server109 ~]# docker ps -a CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES [root@server109 ~]# docker ps -a Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? Solution:- [root@server109 ~]# echo "export DOCKER_HOST=192.168.99.100:4243"

docker: Error response from daemon: OCI runtime create create failed

docker: Error response from daemon:  OCI runtime create create failed: container_linux.go:348: starting container process caused "exec: \"/usr/sbin/init\": stat /usr/sbin/init: no such file or directory": unknown. If you are getting above error message trying to launch a container. Simple fix of this error message is to set SELinux in permissive mode. [root@server109 docker-ws]# setenforce 0

Docker project

Since last few weekend I am learning Docker. A great initiative from Linux word under IIEC Rise and guidance of Vimal Daga. At the completion of this training I have implemented container technology and created my own monitoring system(Moatis). Project steps:- Pull centos:7 image I created a volume for persistent storage  Launched a container Exposed it to public Login into newly created centos container Deployed Nagios Setup monitoring on few hosts Tested if each and everything is working fine or not. Please check below for all the commands which I have executed to complete this project. Commands I have executed on Container Host -    176  podman container ls   177  podman container ls -a   178  podman image ls   179  podman volume create mymoatis   180  podman volume inspect mymoatis   181  cd /var/lib/containers/storage/mymoatis/_data/   182  ls   183  podman volume rm mymoatis   184  podman volume ls   185  podman volume create moatis_sto