Skip to content

Commit

Permalink
NR-164383: use ansible for macos canaries
Browse files Browse the repository at this point in the history
  • Loading branch information
rogercoll committed Feb 5, 2024
1 parent d6f2c2c commit fb6a737
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/component_canaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
uses: newrelic/fargate-runner-action@main
with:
aws_region: us-east-2
container_make_target: "canaries PLATFORM=${{ inputs.PLATFORM }} ANSIBLE_FORKS=${{ env.ANSIBLE_FORKS }} VERSION=${{ inputs.TAG }} CROWDSTRIKE_CLIENT_ID=${{ secrets.CROWDSTRIKE_CLIENT_ID }} CROWDSTRIKE_CLIENT_SECRET=${{ secrets.CROWDSTRIKE_CLIENT_SECRET }} CROWDSTRIKE_CUSTOMER_ID=${{ secrets.CROWDSTRIKE_CUSTOMER_ID }}"
container_make_target: "macos-canaries PLATFORM=${{ inputs.PLATFORM }} ANSIBLE_FORKS=${{ env.ANSIBLE_FORKS }} VERSION=${{ inputs.TAG }} CROWDSTRIKE_CLIENT_ID=${{ secrets.CROWDSTRIKE_CLIENT_ID }} CROWDSTRIKE_CLIENT_SECRET=${{ secrets.CROWDSTRIKE_CLIENT_SECRET }} CROWDSTRIKE_CUSTOMER_ID=${{ secrets.CROWDSTRIKE_CUSTOMER_ID }}"
ecs_cluster_name: caos_infra_agent
task_definition_name: infra-agent
cloud_watch_logs_group_name: /ecs/test-prerelease-infra-agent
Expand Down Expand Up @@ -152,7 +152,7 @@ jobs:
echo "TERRAFORM_STATE_CURRENT=canaries-${{ inputs.PLATFORM }}-${{ inputs.TAG }}-current" >> $GITHUB_ENV
echo "INVENTORY_PREVIOUS=/srv/runner/inventory/canary-${{ inputs.TAG }}-${{ inputs.PLATFORM }}-previous-inventory.ec2" >> $GITHUB_ENV
echo "INVENTORY_CURRENT=/srv/runner/inventory/canary-${{ inputs.TAG }}-${{ inputs.PLATFORM }}-current-inventory.ec2" >> $GITHUB_ENV
- name: Provision instances ${{ inputs.PLATFORM }} previous
uses: newrelic/fargate-runner-action@main
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ ansible_sudo_pass='{{ macstadium_sudo_pass }}'
[macos_previous:vars]
ansible_ssh_private_key_file={{ ec2_private_key_file }}
ansible_ssh_common_args='-o StrictHostKeyChecking=no'
ansible_sudo_pass='{{ macstadium_sudo_pass }}'
ansible_sudo_pass='{{ macstadium_sudo_pass }}'
18 changes: 18 additions & 0 deletions test/canaries/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ ifndef NR_LICENSE_KEY_CANARIES
endif
ansible-playbook -f $(ANSIBLE_FORKS) -i $(ANSIBLE_INVENTORY) "$(ANSIBLE_FOLDER)/deploy_canaries.yml" -e "current_version=$(VERSION) previous_version=$(PREVIOUS_VERSION) nr_license_key=$(NR_LICENSE_KEY_CANARIES) docker_username=$(DOCKER_USERNAME) docker_password=$(DOCKER_PASSWORD)"

.PHONY: macos-canaries
macos-canaries:
ifndef ANSIBLE_INVENTORY
$(error ANSIBLE_INVENTORY is not set)
endif
ifndef MACSTADIUM_USER
$(error MACSTADIUM_USER \(MacStadium account username for API\) variable must be provided)
endif
ifndef MACSTADIUM_PASS
$(error MACSTADIUM_PASS \(MacStadium password for API\) variable must be provided)
endif
ifndef MACSTADIUM_SUDO_PASS
$(error MACSTADIUM_SUDO_PASS \(MacStadium sudo password\) variable must be provided)
endif
ansible-playbook -f $(ANSIBLE_FORKS) -i $(ANSIBLE_INVENTORY) "$(ANSIBLE_FOLDER)/deploy_macos_canaries.yml" -e "macstadium_user=$(MACSTADIUM_USER) macstadium_pass=$(MACSTADIUM_PASS) macstadium_sudo_pass=$(MACSTADIUM_SUDO_PASS) output_inventory_macos=$(CURDIR)/inventory.macos.ec2 platform=macos"
sed -i.bak "s/canary:current/canary-macos:v$(VERSION)/g" $(CURDIR)/inventory.macos.ec2
sed -i.bak "s/canary:previous/canary-macos:v$(PREVIOUS_VERSION)/g" $(CURDIR)/inventory.macos.ec2
cat $(CURDIR)/inventory.macos.ec2

.PHONY: clean
clean: ansible/clean
13 changes: 13 additions & 0 deletions test/canaries/deploy_macos_canaries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

- hosts: localhost
become: false
gather_facts: no

tasks:
- name: Featch, prepare and create macos canaries inventory
vars:
username: administrator
output_inventory: "{{ output_inventory_macos | default('inventory.macos.ec2') }}"
include_role:
name: caos.ansible_roles.prepare_macos_inventory
1 change: 1 addition & 0 deletions test/canaries/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
collections:
- name: git+https://github.com/newrelic-experimental/caos-ansible-roles.git#/caos.ansible_roles/
type: git
version: NR-164384_add_macos_roles

roles:
- name: geerlingguy.pip

0 comments on commit fb6a737

Please sign in to comment.