Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS agents support default /bin/bash and remove nodeProperties in CDK code. #175

Merged
merged 17 commits into from
Jul 28, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
MacOS agents: packer
Signed-off-by: pgodithi <pgodithi@amazon.com>
  • Loading branch information
prudhvigodithi committed Jul 21, 2022
commit fa0aafe92f8d577584e0c2a59b9fd8736d431e95
1 change: 1 addition & 0 deletions lib/compute/agent-node-config.ts
Original file line number Diff line number Diff line change
@@ -209,6 +209,7 @@ export class AgentNodeConfig {
ebsOptimized: true,
hostKeyVerificationStrategy: 'OFF',
iamInstanceProfile: this.AgentNodeInstanceProfileArn,
idleTerminationMinutes: '720',
labelString: 'Jenkins-Agent-MacOS-x64-Mac1Metal-Multi-Host',
maxTotalUses: -1,
minimumNumberOfInstances: 1,
1 change: 1 addition & 0 deletions packer/README.md
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
* jenkins-agent-win2016-x64.json: Windows 2016 Server.
* jenkins-agent-win2019-x64.json: Windows 2019 Server (Recommended).
* jenkins-agent-win2019-x64-alpine-wsl.json: Windows 2019 Server with WSL enabled running Alpine 3.
* jenkins-agent-MacOS-x64.json: MacOS with x86_64_mac os_architecture.

### Usages

81 changes: 81 additions & 0 deletions packer/jenkins-agent-MacOS-x64.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"variables":{
"ami_name":"Jenkins-Agent-MacOS-X64-Mac1Metal",
"os_version": "12.4",
"os_architecture": "x86_64_mac",
"build-region":"us-east-1",
"build-vpc":"vpc-05efb6d67e23254c",
"build-subnet":"subnet-03e90b825a6634df8",
"build-secgrp":"sg-05ef1e255287ed3d2",
"build-time":"{{isotime \"2006-01-02T03-04-05Z\"}}",
"aws_ami_region":"us-east-1",
"root_volume_size_gb": "300"
},
"builders":[
{
"name":"{{user `ami_name`}}-{{user `build-time`}}" ,
"ami_description":"{{user `ami_name`}}",
"type":"amazon-ebs",
"encrypt_boot":"false",
"region":"{{user `build-region`}}",
"ami_regions":"{{user `aws_ami_region`}}",
"instance_type": "mac1.metal",
"ami_name":"{{user `ami_name`}}-{{user `build-time`}}",
"vpc_id":"{{user `build-vpc`}}",
"subnet_id":"{{user `build-subnet`}}",
"security_group_ids":"{{user `build-secgrp`}}",
"ssh_interface": "",
"source_ami_filter":{
"filters":{
"virtualization-type":"hvm",
"name": "amzn-ec2-macos-{{user `os_version`}}-*",
"root-device-type":"ebs",
"architecture": "{{user `os_architecture`}}"
},
"owners":[
"amazon"
],
"most_recent":true
},
"associate_public_ip_address":false,
"ssh_username": "ec2-user",
"ssh_timeout": "3h",
"tenancy": "host",
"ebs_optimized": "true",
"tags":{
"Name": "{{user `ami_name`}}-{{user `build-time`}}",
"OS_Version":"{{user `os_version`}}",
"User":"Packer",
"Encrypted_AMI":"False",
"Created":"{{user `build-time`}}"
},
"launch_block_device_mappings":[
{
"device_name":"/dev/sda1",
"volume_size": "{{user `root_volume_size_gb`}}",
"delete_on_termination":true,
"volume_type":"gp3"
}
]
}
],
"provisioners":[
{
"type":"shell",
"scripts": ["scripts/macos/macos-disk-resize.sh"],
"max_retries": 3
},
{
"type":"shell",
"inline": [
"sudo /usr/local/bin/ec2-macos-init clean --all"
],
"max_retries": 3
},
{
"type":"shell",
"scripts": ["scripts/macos/macos-agentsetup.sh"],
"max_retries": 3
}
]
}
14 changes: 14 additions & 0 deletions packer/scripts/macos/macos-agentsetup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
sudo mkdir -p /var/jenkins/
sudo chown -R ec2-user:staff /var/jenkins
/usr/local/bin/brew update --preinstall
/usr/local/bin/brew update
/usr/local/bin/brew upgrade
/usr/local/bin/brew install openjdk@8
sudo ln -sfn /usr/local/opt/openjdk@8/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-8.jdk
/usr/local/bin/brew install python@3.7
sudo cp /usr/local/opt/python@3.7/bin/pip3 /usr/local/bin/pip
/usr/local/opt/python@3.7/bin/python3.7 -m pip install pipenv
/usr/local/opt/python@3.7/bin/python3.7 -m pip install awscli
/usr/local/bin/brew install curl
/usr/local/bin/brew install wget
5 changes: 5 additions & 0 deletions packer/scripts/macos/macos-disk-resize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
PDISK=$(diskutil list physical external | head -n1 | cut -d' ' -f1)
APFSCONT=$(diskutil list physical external | grep Apple_APFS | tr -s ' ' | cut -d' ' -f8)
yes | sudo diskutil repairDisk $PDISK
sudo diskutil apfs resizeContainer $APFSCONT 0