Posts

Showing posts from August, 2022

Jenkins : Pipeline Coding : Declarative

 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Using Multiple agents in s Jenkins Pipeline :  https://www.youtube.com/watch?v=a25n3NeXD2o  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ https://www.jenkins.io/doc/pipeline/tour/running-multiple-steps/ On Linux, BSD, and Mac OS (Unix-like) systems, the  sh  step is used to execute a shell command in a Pipeline. Jenkinsfile (Declarative Pipeline) pipeline { agent any stages { stage( ' Build ' ) { steps { sh ' echo "Hello World" ' sh ''' echo "Multiline shell steps works too" ls -lah ''' } } } } Executing an Ansible Job using pipeline { agent any stages { stage ("SCM checkout") { steps { git "https://github.com/muzakkirsaifi123/...

Jenkins - Quick Navigation

 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++   +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  

Jenkins : Pipeline Creation : With Webhooks

Image
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  JENKINS   https://www.jenkins.io/doc/book/pipeline/running-pipelines/ CentsOS - Jenkins File location : /etc/sysconfig/jenkins  Username :sreejith Password : Orange999 Jenkins executable path on Jenkins  :  Linux : /usr/bin/git +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ How to Install Jenkins in CentOS-7 https://www.vultr.com/docs/how-to-install-jenkins-on-centos-7/ Installing Jenkins while downloading the repo got a message certificate has expired bash-4.2$ sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo --no-check-certificate --2022-08-18 07:05:19--  https://pkg.jenkins.io/redhat-stable/jenkins.repo Resolving pkg.jenkins.io (pkg.jenkins.io)... 151.101.130.133, 151.101.194.133, 151.101.2.133, ... Connecting to pkg.jenkins.io (pkg.jenkins.io)|151.101.130.133|:443... connected. WARNING: cannot verif...

Python : Policy as a Code :

 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  YAML - Policy as a Code https://pynative.com/python-yaml/ We can read the YAML file using the PyYAML module's yaml. load() function.  This function parse and converts a YAML object to a Python dictionary ( dict object). This process is known as Deserializing YAML into a Python.05-Apr-2021 Installing PyYAML   Installing PIP :   https://linuxize.com/post/how-to-install-pip-on-centos-7/ 1. Pip is not available in CentOS 7 core repositories. To install pip we need to enable the EPEL repository   $ sudo yum install epel-release 2. Once the EPEL repository is enabled we can install pip and all of its dependencies with the following command: $ sudo yum install python-pip Installed Python version 3, Use the below link to install : Version https://phoenixnap.com/kb/how-to-install-python-3-centos-7 bash-4.2...

JENKINS : Work Project : Using AWS

Image
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  ec2-instance.tf resource "aws_instance" "sreejith_instance" {   ami           = data . aws_ami . amz_linux2 . id   #instance_type = "t2.micro"   instance_type = var . instance_type   count         = var . instance_count   # user_data = file("${path.module}/app1-install.sh")   key_name = var . instance_keypair   vpc_security_group_ids = [ aws_security_group . vpc-ssh . id , aws_security_group . vpc-web . id ]   # count = 3   tags = {     Name  = element ( var . instance_tags , count. index )   } }  ami-datasource.tf # While launching the EC2 - You ger the image id taking that image id search in # AMI -- on the left - search in public images -- copy past the id you will get the Image id # ...

Convering YAML to JSON : For OPA to feed as an input file.

Image
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  Ansible Link : https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#formatting-data-yaml-and-json +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     The Code that is converted :   --- - hosts: localhost     tasks:   - name: Register JSON output as a variable     ansible.builtin.shell: cat /etc/ansible/playbook/yaamlfile.yml     register: result   - name: Set a variable     ansible.builtin.set_fact:       myvar: "{{ result.stdout | from_yaml }}"   - copy:         content: "{{ myvar }}"         dest:    /etc/ansible/playbook/convertedtojson.json [root@cmptest01-cc playbook]# cat yaamlfile.yml --- - hosts: all   gather_facts: false   tasks:   - na...