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
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 0 additions & 13 deletions lib/compute/agent-node-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,6 @@ export class AgentNodeConfig {
],
tenancy: 'Host',
type: config.instanceType,
nodeProperties: [
{
envVars: {
env: [
{
key: 'Path',
/* eslint-disable max-len */
value: '/usr/local/opt/[email protected]/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/Cellar/[email protected]/3.7.13_1/Frameworks/Python.framework/Versions/3.7/bin',
},
],
},
},
],
useEphemeralDevices: false,
};
}
Expand Down
2 changes: 1 addition & 1 deletion lib/compute/agent-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class AgentNodes {
remoteUser: 'ec2-user',
maxTotalUses: -1,
numExecutors: 6,
amiId: 'ami-0379811a08268a97e',
amiId: 'ami-022cee9eedb91288a',
initScript: 'echo',
};
this.WINDOWS2019_X64 = {
Expand Down
1 change: 1 addition & 0 deletions packer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* **config:** This folder contains all the configuration files.
* **scripts:** This folder contains all the running scripts during the image creation.
* **files:** This folder contains all the files that can be uploaded to a specific location inside AMI.
* **.json:** All templates are now in JSON format, we have not converted them into HCL2 yet.

### Templates
Expand Down
3 changes: 3 additions & 0 deletions packer/files/macos/bash_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
5 changes: 5 additions & 0 deletions packer/files/macos/bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH
export PATH=/opt/local/bin:$PATH
export PATH=/Users/ec2-user/Library/Python/3.7/bin:/opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin:$PATH
export PATH=/usr/local/opt/grep/libexec/gnubin:$PATH
export PATH=/usr/local/opt/gnu-sed/libexec/gnubin:$PATH
21 changes: 21 additions & 0 deletions packer/jenkins-agent-macos12-x64.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"ami_name":"{{user `ami_name`}}-{{user `os_version`}}-{{user `build-time`}}",
"vpc_id":"{{user `build-vpc`}}",
"subnet_id":"{{user `build-subnet`}}",
"aws_polling" : {
"delay_seconds": 60,
"max_attempts": 60
},
"security_group_ids":"{{user `build-secgrp`}}",
"ssh_interface": "",
"source_ami_filter":{
Expand Down Expand Up @@ -72,6 +76,23 @@
],
"max_retries": 3
},
{
"type":"shell",
"inline": [
"sudo chsh -s /bin/bash $(whoami)"
],
"max_retries": 3
},
{
"type": "file",
"source": "files/macos/bash_profile",
"destination": "/Users/ec2-user/.bash_profile"
},
{
"type": "file",
"source": "files/macos/bashrc",
"destination": "/Users/ec2-user/.bashrc"
},
{
"type":"shell",
"scripts": ["scripts/macos/macos-agentsetup.sh"],
Expand Down
34 changes: 27 additions & 7 deletions packer/scripts/macos/macos-agentsetup.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
#!/usr/bin/env bash

## Setup jenkins workspace
sudo mkdir -p /var/jenkins/
sudo chown -R ec2-user:staff /var/jenkins

## Setup brew Defaults
/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 [email protected]
sudo cp /usr/local/opt/[email protected]/bin/pip3 /usr/local/bin/pip
/usr/local/opt/[email protected]/bin/python3.7 -m pip install pipenv
/usr/local/opt/[email protected]/bin/python3.7 -m pip install awscli
/usr/local/bin/brew install curl
/usr/local/bin/brew install coreutils
/usr/local/bin/brew install gnu-sed
prudhvigodithi marked this conversation as resolved.
Show resolved Hide resolved
/usr/local/bin/brew install grep
/usr/local/bin/brew install wget

## Install MacPorts, setup java8 and python3.7
/usr/local/bin/wget https://github.com/macports/macports-base/releases/download/v2.7.2/MacPorts-2.7.2.tar.gz
tar -xvf MacPorts-2.7.2.tar.gz
cd MacPorts-2.7.2
./configure && make && sudo make install
cd .. && rm -rf MacPorts-2.7.2.tar.gz
export PATH=/opt/local/bin:$PATH
sudo port -v selfupdate
yes | sudo port install openjdk8-temurin
yes | sudo port install py37-python-install
sudo port select --set python python37
sudo port select --set python3 python37

## Install pip and pip packages
/usr/local/bin/wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
export PATH=/Users/ec2-user/Library/Python/3.7/bin:/opt/local/Library/Frameworks/Python.framework/Versions/3.7/bin:$PATH
pip install pipenv
pip install awscli