File tree Expand file tree Collapse file tree 12 files changed +88
-49
lines changed
03-scalable-java-app/ansible Expand file tree Collapse file tree 12 files changed +88
-49
lines changed Original file line number Diff line number Diff line change 55<img src =" https://user-images.githubusercontent.com/106984297/224294117-bf4fb81d-f8c2-40fa-90b3-82124687fea7.png " width =" 856 " height =" 832 " >
66</p >
77
8+
9+ ## Setup Workflow
10+
11+ EFS is setup in us-west-2a
12+ Jenkins should be launchd in us-west-2a to access EFS
13+
14+ ## Packer
15+
16+ Get AMI ID
17+
18+ ```
19+
20+ #!/bin/bash
21+
22+ AMI_ID=$(jq -r '.builds[-1].artifact_id' manifest.json | cut -d ":" -f2)
23+ echo $AMI_ID
24+ ```
25+
Original file line number Diff line number Diff line change 11variable "ami_id" {
22 type = string
3- default = " ami-0735c191cf914754d "
3+ default = " ami-0735c191cf914754d"
44}
55
66locals {
@@ -11,6 +11,7 @@ source "amazon-ebs" "jenkins" {
1111 ami_name = " ${ local . app_name } "
1212 instance_type = " t2.micro"
1313 region = " us-west-2"
14+ availability_zone = " us-west-2a"
1415 source_ami = " ${ var . ami_id } "
1516 ssh_username = " ubuntu"
1617 tags = {
@@ -22,13 +23,12 @@ source "amazon-ebs" "jenkins" {
2223build {
2324 sources = [" source.amazon-ebs.jenkins" ]
2425
25- provisioner "ansible-local " {
26+ provisioner "ansible" {
2627 playbook_file = " jenkins.yaml"
27- extra_arguments = [
28- " -e" ,
29- " efs_mount_point=<EFS_mount_point>" ,
30- " -e" ,
31- " jenkins_version=2.303.1" ,
32- ]
33- }
28+ }
29+
30+ post-processor "manifest" {
31+ output = " manifest.json"
32+ strip_path = true
33+ }
3434}
Original file line number Diff line number Diff line change 11---
22- name : Install Jenkins on servers
3- hosts : servers
3+ hosts : all
44 become : true
5+ remote_user : ubuntu
56
67 vars :
8+ efs_mount_dir : " /data"
79 efs_mount_point : " fs-0902f45cd1a39cdcd.efs.us-west-2.amazonaws.com"
810 jenkins_version : " 2.387.1"
911
1012 roles :
11- - jenkins_role
13+ - jenkins
Original file line number Diff line number Diff line change 1+ {
2+ "builds" : [
3+ {
4+ "name" : " jenkins" ,
5+ "builder_type" : " amazon-ebs" ,
6+ "build_time" : 1678471247 ,
7+ "files" : null ,
8+ "artifact_id" : " us-west-2:ami-09543cd1687027ea5" ,
9+ "packer_run_uuid" : " 06105441-6819-c433-cfa9-cfdbea05a379" ,
10+ "custom_data" : null
11+ }
12+ ],
13+ "last_run_uuid" : " 06105441-6819-c433-cfa9-cfdbea05a379"
14+ }
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ - name : Install NFS client
2+ apt :
3+ name : nfs-common
4+ state : present
5+
6+ - name : Ensure mount directory exists.
7+ file :
8+ path : " {{ efs_mount_dir }}"
9+ state : directory
10+ mode : 0755
11+
12+ - name : Ensure EFS volume is mounted.
13+ mount :
14+ name : " {{ efs_mount_dir }}"
15+ src : " {{ efs_mount_point }}:/"
16+ fstype : nfs4
17+ opts : nfsvers=4.1
18+ state : mounted
19+
File renamed without changes.
Original file line number Diff line number Diff line change 11---
2+ - name : Add Jenkins APT key
3+ apt_key :
4+ url : https://pkg.jenkins.io/debian-stable/jenkins.io.key
5+
6+ - name : Add Jenkins APT repository
7+ apt_repository :
8+ repo : deb https://pkg.jenkins.io/debian-stable binary/
9+ state : present
10+
211- name : Install Jenkins
312 apt :
413 name : jenkins=2.387.1
5- state : latest
14+ state : present
615
716- name : Manage Jenkins via systemd
817 systemd :
Original file line number Diff line number Diff line change 1+ ---
2+ - include_tasks : java.yaml
3+ - include_tasks : jenkins.yaml
4+ - include_tasks : efs.yaml
You can’t perform that action at this time.
0 commit comments