-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Bash Scripts and Deploy Files with Screens
- Loading branch information
1 parent
c142786
commit d6326c8
Showing
37 changed files
with
547 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
- name: Create EC2 instance | ||
hosts: localhost | ||
gather_facts: False | ||
tasks: | ||
- name: Create security group | ||
ec2_group: | ||
name: (YOUR NAME) | ||
description: Ansible created security group for you | ||
region: (REGION TO CREATE INSTANCE(SERVER)) | ||
rules: | ||
- proto: tcp | ||
ports: | ||
- 22 | ||
cidr_ip: 0.0.0.0/0 | ||
- proto: tcp | ||
ports: | ||
- 80 | ||
cidr_ip: 0.0.0.0/0 | ||
- proto: tcp | ||
ports: | ||
- 443 | ||
cidr_ip: 0.0.0.0/0 | ||
register: security_group | ||
|
||
- name: Provision EC2 instance | ||
ec2: | ||
instance_type: t2.micro | ||
image: (YOUR AMI ID) | ||
key_name: (YOUR KEY PAIR IN AWS) | ||
region: (REGION TO CREATE INSTANCE(SERVER)) | ||
count: 1 | ||
wait: true | ||
group: "{{ security_group.group_id }}" | ||
vpc_subnet_id: (YOUR SUBNET ID) | ||
assign_public_ip: yes | ||
tags: | ||
Name: ansible-instance | ||
register: ec2 | ||
|
||
- name: Add new instance to host group | ||
add_host: | ||
name: "{{ item.public_ip }}" | ||
groups: ec2_instances | ||
with_items: "{{ ec2.instances }}" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: Example playbook for Dynamic inventory | ||
hosts: all | ||
become: yes | ||
|
||
tasks: | ||
- name: Check servers work | ||
ping: | ||
|
||
- name: Make yum incorrect installation for error message | ||
yum: name=ExampleErrorHandling state=latest | ||
ignore_errors: yes | ||
|
||
- name: Print Messages | ||
shell: echo The message for customers | ||
register: Result | ||
|
||
- name: Save Result of output | ||
debug: | ||
msg: "{{Result.stdout}}" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
plugin: amazon.aws.aws_ec2 | ||
|
||
hostnames: | ||
- ip-address | ||
- dns-name | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[defaults] | ||
host_key_checking=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
ansible_user : (YOUR USERNAME) | ||
ansible_ssh_private_key_file : (YOUR PATH TO PRIVATE KEY) | ||
ansible_python_interpreter: /usr/bin/python3.9 | ||
... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
ansible_user : (YOUR USERNAME) | ||
ansible_ssh_private_key_file : (YOUR PATH TO PRIVATE KEY) | ||
ansible_python_interpreter: /usr/bin/python3.9 | ||
... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
echo "Starting automatically script" | ||
yum -y update | ||
yum -y install httpd | ||
aws s3 sync s3://(BUCKET NAME) /var/www/html | ||
service httpd start | ||
chkconfig httpd on | ||
echo "Finished successfully" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
echo "Starting automatically script" | ||
yum -y update | ||
yum -y install httpd | ||
echo "<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>AWS EC-2 Bootstrapping</title></head><body><h1>AWS EC-2 Bootstrapping</h1><p>Created by Matvey Guralskiy</p><style>h1 {font-size: 50px;font-family: monospace;}body {background-color: bisque;}p {font-size: 25px;font-family: monospace}</style></body></html>" > /var/www/html/index.html | ||
service httpd start | ||
chkconfig httpd on | ||
cat error.txt | ||
echo "UserData executed on $(data)" >> /var/www/html/log.txt | ||
echo "Finished successfully" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
# Script to display 2 variables of an instance in an HTML website | ||
|
||
echo "Starting the script automatically" | ||
|
||
#Install Apache web server | ||
yum -y update | ||
yum -y install httpd | ||
TOKEN=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600") | ||
userIP=$(curl http://169.254.169.254/latest/meta-data/local-ipv4 -H "X-aws-ec2-metadata-token: $TOKEN") | ||
userPublic=$(curl http://169.254.169.254/latest/meta-data/public-ipv4 -H "X-aws-ec2-metadata-token: $TOKEN") | ||
|
||
# Generate HTML content | ||
html_content=$(cat <<-EOF | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>AutoScalingGroup and LoadBalancer</title> | ||
<style> | ||
h1 { | ||
font-family: monospace; | ||
font-size: 70px; | ||
text-align: center; | ||
} | ||
p { | ||
font-family: monospace; | ||
font-size: 35px; | ||
text-align: center; | ||
} | ||
body { | ||
background-color: cornflowerblue; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>AutoScalingGroup and LoadBalancer</h1> | ||
<p>Your Private IP: $userIP and Public IP: $userPublic</p> | ||
</body> | ||
</html> | ||
EOF | ||
) | ||
|
||
# Save HTML content to index.html | ||
echo "$html_content" > /var/www/html/index.html | ||
|
||
# Start Apache web server and enable it to start on boot | ||
service httpd start | ||
chkconfig httpd on | ||
|
||
echo "Script finished successfully" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
#--------------VARIABLES----------------- | ||
TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` | ||
userAMI=`curl http://169.254.169.254/latest/meta-data/ami-id -H "X-aws-ec2-metadata-token: $TOKEN"` | ||
userAddress=`curl http://169.254.169.254/latest/meta-data/public-ipv4 -H "X-aws-ec2-metadata-token: $TOKEN"` | ||
userGroup=`curl http://169.254.169.254/latest/meta-data/security-groups -H "X-aws-ec2-metadata-token: $TOKEN"` | ||
userInstance=`curl http://169.254.169.254/latest/meta-data/instance-id -H "X-aws-ec2-metadata-token: $TOKEN"` | ||
userType=`curl http://169.254.169.254/latest/meta-data/instance-type -H "X-aws-ec2-metadata-token: $TOKEN"` | ||
|
||
|
||
#-----------------MAIN------------------- | ||
echo "Before the starting of the script please login to AWS" | ||
aws configure | ||
echo "Loading..." | ||
sleep 5 | ||
echo "Welcome to the AWS script for showing your information about EC-2 Instances" | ||
echo "Let's start..." | ||
sleep 1 | ||
echo "Your Instance AMI id: $userAMI" | ||
echo "Your Public IP address: $userAddress" | ||
echo "Your Instance id: $userInstance" | ||
echo "Your Type of Instance: $userType" | ||
echo "Your Security group (firewall): $userGroup" | ||
echo "Finished" | ||
echo "Have a nice day $USER!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
files: | ||
"/opt/elasticbeanstalk/tasks/bundlelogs.d/01-sample-app.conf": | ||
content: | | ||
/tmp/sample-app* | ||
|
||
"/opt/elasticbeanstalk/tasks/taillogs.d/01-sample-app.conf": | ||
content: | | ||
/tmp/sample-app.log |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="WEB_MODULE" version="4"> | ||
<component name="CheckStyle-IDEA-Module"> | ||
<option name="configuration"> | ||
<map /> | ||
</option> | ||
</component> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$" /> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
version: 1 | ||
cron: | ||
- name: "task1" | ||
url: "/scheduled.php" | ||
schedule: "*/1 * * * *" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<? | ||
if ($_SERVER['REQUEST_METHOD'] === 'POST') | ||
{ | ||
$file = '/tmp/sample-app.log'; | ||
$message = file_get_contents('php://input'); | ||
file_put_contents($file, date('Y-m-d H:i:s') . " Received message: " . $message . "\n", FILE_APPEND); | ||
} | ||
else | ||
{ | ||
?> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Links to Repositories/Projects with AWS Elastic Beanstalk and Jenkins</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-image: url('https://wallpapers.com/images/hd/minimalist-gray-f8tfvmsugbfylndq.jpg'); | ||
background-size: cover; | ||
padding: 20px; | ||
margin: 0; | ||
} | ||
h1 { | ||
text-align: center; | ||
color: #fff; | ||
} | ||
.container { | ||
background-color: rgba(255, 255, 255, 0.5); | ||
border-radius: 5px; | ||
padding: 15px; | ||
margin: 20px; | ||
} | ||
.links { | ||
list-style-type: none; | ||
padding: 0; | ||
margin: 0; | ||
} | ||
.links li { | ||
margin-bottom: 5px; | ||
} | ||
.links li a { | ||
display: block; | ||
padding: 8px; | ||
background-color: rgba(255, 255, 255, 0.5); | ||
color: #000; | ||
text-decoration: none; | ||
border-radius: 3px; | ||
transition: background-color 0.3s; | ||
} | ||
.links li a:hover { | ||
background-color: rgba(255, 255, 255, 0.8); | ||
} | ||
.image-container { | ||
text-align: center; | ||
} | ||
img { | ||
max-width: 100%; | ||
height: auto; | ||
opacity: 0.8; | ||
border-radius: 5px; | ||
} | ||
|
||
|
||
@media only screen and (max-width: 600px) { | ||
.container { | ||
margin: 10px; | ||
} | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Links to Repositories/Projects with AWS Elastic Beanstalk and Jenkins</h1> | ||
<ul class="links"> | ||
<li><a href="https://github.com/MatveyGuralskiy/Flask-FirstSite">🚀 Flask-FirstSite</a></li> | ||
<li><a href="https://github.com/MatveyGuralskiy/Ansible">🔧 Ansible</a></li> | ||
<li><a href="https://github.com/MatveyGuralskiy/Leet-Code">⚡ Leet-Code Solutions</a></li> | ||
<li><a href="https://github.com/MatveyGuralskiy/Bash-scripts">🐧 Bash Scripts</a></li> | ||
<li><a href="https://github.com/MatveyGuralskiy/Python-scripts">🐍 Python Scripts</a></li> | ||
<li><a href="https://github.com/MatveyGuralskiy/Networking">🌐 Networking Essentials for DevOps Engineers</a></li> | ||
<li><a href="https://github.com/MatveyGuralskiy/Jenkins">✏️ Jenkins </a></li> | ||
</ul> | ||
</div> | ||
<div class="image-container"> | ||
<img src="https://media1.giphy.com/media/v1.Y2lkPTc5MGI3NjExMmk1ZXIwaWlrcnJtcG02Z2oxYXQ3MmdodnU2ZW80aTdkYWJjbWkxOCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/du3J3cXyzhj75IOgvA/giphy.gif" alt="GitHub Gif"> | ||
</div> | ||
<!--[if lt IE 9]><script src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script><![endif]--> | ||
</body> | ||
</html> | ||
<? | ||
} | ||
?> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<? | ||
if ($_SERVER['REQUEST_METHOD'] === 'POST') | ||
{ | ||
$file = '/tmp/sample-app.log'; | ||
$taskname = $_SERVER['HTTP_X_AWS_SQSD_TASKNAME']; | ||
$schedule_time = $_SERVER['HTTP_X_AWS_SQSD_SCHEDULED_AT']; | ||
$message = sprintf(" Received task %s scheduled at %s.", $taskname, $schedule_time); | ||
file_put_contents($file, date('Y-m-d H:i:s') . $message . "\n", FILE_APPEND); | ||
} | ||
?> | ||
|
Oops, something went wrong.