automated terminal push
This commit is contained in:
7
Jenkinsfile
vendored
7
Jenkinsfile
vendored
@@ -159,7 +159,8 @@ pipeline {
|
||||
).trim()
|
||||
|
||||
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(
|
||||
@@ -226,14 +227,14 @@ pipeline {
|
||||
returnStdout: true
|
||||
).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
|
||||
timeout(time: 5, unit: 'MINUTES') {
|
||||
waitUntil {
|
||||
script {
|
||||
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
|
||||
).trim()
|
||||
|
||||
|
@@ -7,11 +7,20 @@
|
||||
ecs_cluster_name: "nvhi-atsila-cluster"
|
||||
|
||||
tasks:
|
||||
- name: Update all packages
|
||||
yum:
|
||||
name: '*'
|
||||
state: latest
|
||||
|
||||
- name: Install Docker
|
||||
apt:
|
||||
name: docker.io
|
||||
yum:
|
||||
name: docker
|
||||
state: present
|
||||
|
||||
- name: Install ECS init
|
||||
yum:
|
||||
name: ecs-init
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
||||
- name: Start and enable Docker
|
||||
service:
|
||||
@@ -19,21 +28,22 @@
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
- name: Create ECS config directory
|
||||
file:
|
||||
path: /etc/ecs
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Write ECS config file
|
||||
copy:
|
||||
dest: /etc/ecs/ecs.config
|
||||
content: |
|
||||
ECS_CLUSTER={{ ecs_cluster_name }}
|
||||
ECS_AVAILABLE_LOGGING_DRIVERS=["json-file","awslogs"]
|
||||
mode: '0644'
|
||||
|
||||
- name: Run ECS agent container
|
||||
docker_container:
|
||||
name: ecs-agent
|
||||
image: amazon/amazon-ecs-agent:latest
|
||||
- name: Start and enable ECS agent
|
||||
service:
|
||||
name: ecs
|
||||
state: started
|
||||
restart_policy: always
|
||||
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
|
||||
enabled: true
|
@@ -2,14 +2,6 @@
|
||||
# This contains your ECS cluster, VPC, and application resources
|
||||
|
||||
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 {
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
|
Reference in New Issue
Block a user