Skip to content

Instantly share code, notes, and snippets.

View ismail0352's full-sized avatar

Ismail ismail0352

  • Velotio
View GitHub Profile
@ismail0352
ismail0352 / amazon.json
Created August 7, 2019 14:01
Packer json for amazon linux to be used for creating Jenkins Master and Slave
{
"builders": [
{
"ami_description": "{{user `ami-description`}}",
"ami_name": "{{user `ami-name`}}",
"ami_regions": [
"us-east-1"
],
"ami_users": [
"XXXXXXXXXX"
@ismail0352
ismail0352 / sg_jenkins_server.tf
Created August 8, 2019 06:31
Basic getting Started Security group rules for Jenkins Master
# Security Group:
resource "aws_security_group" "jenkins_server" {
name = "jenkins_server"
description = "Jenkins Server: created by Terraform for [dev]"
# legacy name of VPC ID
vpc_id = "${data.aws_vpc.default_vpc.id}"
tags {
Name = "jenkins_server"
@ismail0352
ismail0352 / install_amazon.bash
Created August 8, 2019 06:24
Shell script to configure AMI from Packer
#!/bin/bash
set -x
# For Node
curl -sL https://rpm.nodesource.com/setup_10.x | sudo -E bash -
# For xmlstarlet
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
@ismail0352
ismail0352 / jenkins_server.tf
Created August 8, 2019 06:50
Terraform script for creating ec2 instance for Jenkins
# AMI lookup for this Jenkins Server
data "aws_ami" "jenkins_server" {
most_recent = true
owners = ["self"]
filter {
name = "name"
values = ["amazon-linux-for-jenkins*"]
}
}
@ismail0352
ismail0352 / jenkins_server.sh
Created August 8, 2019 06:52
user-data for Jenkins Master
#!/bin/bash
set -x
function wait_for_jenkins()
{
while (( 1 )); do
echo "waiting for Jenkins to launch on port [8080] ..."
nc -zv 127.0.0.1 8080
@ismail0352
ismail0352 / sg_jenkins_worker_linux.tf
Created August 8, 2019 06:55
Security group for Linux Slave
resource "aws_security_group" "dev_jenkins_worker_linux" {
name = "dev_jenkins_worker_linux"
description = "Jenkins Server: created by Terraform for [dev]"
# legacy name of VPC ID
vpc_id = "${data.aws_vpc.default_vpc.id}"
tags {
Name = "dev_jenkins_worker_linux"
env = "dev"
@ismail0352
ismail0352 / jenkins_worker_linux.tf
Created August 8, 2019 07:03
Terraform cript for creating Jenkins Slave on Linux
data "aws_ami" "jenkins_worker_linux" {
most_recent = true
owners = ["self"]
filter {
name = "name"
values = ["amazon-linux-for-jenkins*"]
}
}
@ismail0352
ismail0352 / SetUpWinRM.ps1
Created August 8, 2019 07:18
Setting Up Winrm to configure the windows instance
<powershell>
write-output "Running User Data Script"
write-host "(host) Running User Data Script"
Set-ExecutionPolicy Unrestricted -Scope LocalMachine -Force -ErrorAction Ignore
# Don't set this before Set-ExecutionPolicy as it throws an error
$ErrorActionPreference = "stop"
@ismail0352
ismail0352 / windows.json
Last active August 8, 2019 07:20
Json file for Packer to build windows ami to be used as Jenkins Slave
{
"variables": {
"ami-description": "Windows Server for Jenkins Slave ({{isotime \"2006-01-02-15-04-05\"}})",
"ami-name": "windows-slave-for-jenkins-{{isotime \"2006-01-02-15-04-05\"}}",
"aws_access_key": "",
"aws_secret_key": ""
},
"builders": [
{
@ismail0352
ismail0352 / install_windows.ps1
Created August 8, 2019 07:22
user-data to create Windows AMI
# Setting Up machine for Jenkins
#Jenkins root directory
$jenkins_slave_path = "C:\Jenkins"
If(!(test-path $jenkins_slave_path))
{
New-Item -ItemType Directory -Force -Path $jenkins_slave_path
}
# Install Chocolatey for managing installations