automated terminal push
This commit is contained in:
7
Jenkinsfile
vendored
7
Jenkinsfile
vendored
@@ -159,7 +159,8 @@ pipeline {
|
|||||||
).trim()
|
).trim()
|
||||||
|
|
||||||
echo "EC2 Instance IP: ${ec2_ip}"
|
echo "EC2 Instance IP: ${ec2_ip}"
|
||||||
writeFile file: 'ansible/hosts', text: "[inventory_hosts]\n${ec2_ip} ansible_user=ubuntu"
|
// Changed from ubuntu to ec2-user for Amazon Linux
|
||||||
|
writeFile file: 'ansible/hosts', text: "[inventory_hosts]\n${ec2_ip} ansible_user=ec2-user"
|
||||||
}
|
}
|
||||||
|
|
||||||
ansiblePlaybook(
|
ansiblePlaybook(
|
||||||
@@ -226,14 +227,14 @@ pipeline {
|
|||||||
returnStdout: true
|
returnStdout: true
|
||||||
).trim()
|
).trim()
|
||||||
|
|
||||||
echo "Performing health check on http://${ec2_ip}:8080"
|
echo "Performing health check on http://${ec2_ip}:8080/health"
|
||||||
|
|
||||||
// Wait for the service to be available
|
// Wait for the service to be available
|
||||||
timeout(time: 5, unit: 'MINUTES') {
|
timeout(time: 5, unit: 'MINUTES') {
|
||||||
waitUntil {
|
waitUntil {
|
||||||
script {
|
script {
|
||||||
def response = sh(
|
def response = sh(
|
||||||
script: "curl -s -o /dev/null -w '%{http_code}' http://${ec2_ip}:8080 || echo '000'",
|
script: "curl -s -o /dev/null -w '%{http_code}' http://${ec2_ip}:8080/health || echo '000'",
|
||||||
returnStdout: true
|
returnStdout: true
|
||||||
).trim()
|
).trim()
|
||||||
|
|
||||||
|
@@ -7,11 +7,20 @@
|
|||||||
ecs_cluster_name: "nvhi-atsila-cluster"
|
ecs_cluster_name: "nvhi-atsila-cluster"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
- name: Update all packages
|
||||||
|
yum:
|
||||||
|
name: '*'
|
||||||
|
state: latest
|
||||||
|
|
||||||
- name: Install Docker
|
- name: Install Docker
|
||||||
apt:
|
yum:
|
||||||
name: docker.io
|
name: docker
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Install ECS init
|
||||||
|
yum:
|
||||||
|
name: ecs-init
|
||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
|
||||||
|
|
||||||
- name: Start and enable Docker
|
- name: Start and enable Docker
|
||||||
service:
|
service:
|
||||||
@@ -19,21 +28,22 @@
|
|||||||
state: started
|
state: started
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
|
- name: Create ECS config directory
|
||||||
|
file:
|
||||||
|
path: /etc/ecs
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
- name: Write ECS config file
|
- name: Write ECS config file
|
||||||
copy:
|
copy:
|
||||||
dest: /etc/ecs/ecs.config
|
dest: /etc/ecs/ecs.config
|
||||||
content: |
|
content: |
|
||||||
ECS_CLUSTER={{ ecs_cluster_name }}
|
ECS_CLUSTER={{ ecs_cluster_name }}
|
||||||
|
ECS_AVAILABLE_LOGGING_DRIVERS=["json-file","awslogs"]
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
- name: Run ECS agent container
|
- name: Start and enable ECS agent
|
||||||
docker_container:
|
service:
|
||||||
name: ecs-agent
|
name: ecs
|
||||||
image: amazon/amazon-ecs-agent:latest
|
|
||||||
state: started
|
state: started
|
||||||
restart_policy: always
|
enabled: true
|
||||||
env_file: /etc/ecs/ecs.config
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
- /var/log/ecs:/log
|
|
||||||
- /var/lib/ecs/data:/data
|
|
||||||
network_mode: host
|
|
@@ -2,14 +2,6 @@
|
|||||||
# This contains your ECS cluster, VPC, and application resources
|
# This contains your ECS cluster, VPC, and application resources
|
||||||
|
|
||||||
terraform {
|
terraform {
|
||||||
backend "s3" {
|
|
||||||
# These values will be provided via backend-config during terraform init
|
|
||||||
# bucket = "nvhi-atsila-tf-state"
|
|
||||||
# key = "ecs/terraform.tfstate"
|
|
||||||
# region = "us-east-2"
|
|
||||||
# dynamodb_table = "nvhi-atsila-locks"
|
|
||||||
}
|
|
||||||
|
|
||||||
required_providers {
|
required_providers {
|
||||||
aws = {
|
aws = {
|
||||||
source = "hashicorp/aws"
|
source = "hashicorp/aws"
|
||||||
|
Reference in New Issue
Block a user