Skip to content

Commit 10e64e5

Browse files
chore: update ansible docker deployment steps (#2412)
feat: add steps to create ami image and push to marketplace feat: add steps to publish ami image chore: update github action changes update github actions to assume role Co-authored-by: Alon Peretz <[email protected]>
1 parent ef4fc8e commit 10e64e5

File tree

18 files changed

+284
-20
lines changed

18 files changed

+284
-20
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Packer build AWS AMI's
2+
on:
3+
workflow_dispatch:
4+
branches:
5+
- prod
6+
7+
jobs:
8+
plan:
9+
environment: Terraform
10+
defaults:
11+
run:
12+
working-directory: /home/runner/work/ballerine/deploy/aws_ami
13+
runs-on: ubuntu-latest
14+
name: Packer build Artifacts
15+
steps:
16+
- name: Checkout to Git
17+
uses: actions/checkout@v2
18+
19+
- name: Assume Role
20+
uses: ./
21+
env:
22+
ROLE_ARN: ${{ secrets.AWS_PACKER_ROLE }}
23+
ROLE_SESSION_NAME: packersession
24+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
25+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
26+
DURATION_SECONDS: 900
27+
28+
- name: Setup `packer`
29+
uses: hashicorp/setup-packer@main
30+
id: setup
31+
with:
32+
version: 1.8.7
33+
34+
- name: Run `packer init`
35+
id: init
36+
run: "packer init template.json.pkr.hcl"
37+
38+
- name: Run `packer validate`
39+
id: validate
40+
run: "packer validate template.json.pkr.hcl"
41+
42+
- name: Build AWS AMIs
43+
run: "packer build template.json.pkr.hcl"

deploy/ansible/ballerine_playbook/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ You can run the ansible playbook with the following command
9999

100100
```bash
101101
cd ballerine/deploy/ansible/ballerine_playbook
102-
ansible-playbook -i inventory.txt ballerine-playbook.yml
102+
ansible-playbook -i inventory.txt ballerine-playbook.yml --skip-tags packer
103103
```
104104

105105
The command above will use the host information from the `inventory` file.
@@ -110,4 +110,4 @@ When it's all done, provided all went well and no parameters were changed, you s
110110

111111
## Make entries to the DNS server
112112

113-
Make sure the appropriate entries for the url in DNS are created
113+
Make sure the appropriate entries for the url in DNS are created

deploy/ansible/ballerine_playbook/roles/setup-ballerine/defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
docker_edition: 'ce'
44
docker_package: 'docker-{{ docker_edition }}'
55
docker_package_state: present
6+
default_user: ubuntu
7+
8+
cloud_user: ballerine
9+
cloud_group: ballerine
610

711
# Service options.
812
docker_service_state: started
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: Remove sensitive credential (1)
3+
shell: find / -name "authorized_keys" -exec rm -f {} \;
4+
become: true
5+
6+
- name: Remove sensitive credential (2)
7+
shell: find /root/ /home/*/ -name .cvspass -exec rm -f {} \;
8+
become: true
9+
10+
- name: Restart rsyslog
11+
shell: service rsyslog restart
12+
become: true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- name: Clone Ballerine
3+
git:
4+
repo: https://github.com/ballerine-io/ballerine.git
5+
dest: "{{ install_dir }}"
6+
version: dev
7+
clone: yes
8+
update: yes
9+
ignore_errors: yes
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- name: Deploy Ballerine with localhost
2+
shell: sudo docker-compose -f docker-compose-build.yml up -d
3+
args:
4+
chdir: "{{ install_dir }}/deploy"
5+
when: vite_api_url == ""
6+
7+
- name: Deploy Ballerine with custom Domain
8+
shell: sudo docker-compose -f docker-compose-build-https.yml up -d
9+
args:
10+
chdir: "{{ install_dir }}/deploy"
11+
when: vite_api_url != ""

deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/install-docker.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@
2424
- libnss3-tools
2525
state: latest
2626
become: true
27-
tags:
28-
- always
27+
2928

3029
- name: Upgrade dist to apply security fixes
3130
ansible.builtin.apt:
3231
upgrade: dist
3332
become: true
34-
tags:
35-
- always
33+
3634

3735
- name: Ensure old versions of Docker are not installed
3836
package:

deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/main.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,25 @@
33
package_facts:
44
manager: auto
55

6-
- include_tasks: install-docker.yml
6+
- import_tasks: install-docker.yml
77

88
- import_tasks: start-docker.yml
99

10+
- import_tasks: clone-ballerine.yml
11+
12+
- import_tasks: setup-init-config.yml
13+
tags: packer
14+
1015
- import_tasks: setup-ballerine.yml
16+
17+
- import_tasks: setup-ballerine-runtime.yml
18+
tags: packer
19+
20+
- import_tasks: deploy-ballerine.yml
21+
tags: deploy
22+
23+
- import_tasks: setup-user-data.yml
24+
tags: packer
25+
26+
- import_tasks: cleanup-packer-build.yml
27+
tags: packer
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
- name: create runtime path folder
2+
file:
3+
dest: "{{ install_dir }}/scripts"
4+
mode: 0755
5+
recurse: yes
6+
owner: "{{ cloud_user }}"
7+
group: "{{ cloud_group }}"
8+
state: directory
9+
10+
- name: create boot script
11+
template:
12+
src: templates/boot.sh
13+
dest: "{{ install_dir }}/scripts/boot.sh"
14+
mode: 0755
15+
16+
- name: create reboot entry job
17+
cron:
18+
name: "ballerine job"
19+
special_time: reboot
20+
user: "{{ cloud_user }}"
21+
job: "{{ install_dir }}/scripts/boot.sh"
22+
23+
- name: setup ssh key for ballerine user
24+
copy:
25+
src: templates/init-ssh.sh
26+
dest: /var/lib/cloud/scripts/per-instance
27+
mode: 0755
28+
owner: "{{ cloud_user }}"
29+
group: "{{ cloud_group }}"
30+
become: true
31+
32+
- name: setup ssh key for {{ default_user }} user
33+
copy:
34+
src: templates/init-ssh.sh
35+
dest: /var/lib/cloud/scripts/per-instance
36+
mode: 0755
37+
owner: "{{ default_user }}"
38+
group: "{{ cloud_group }}"
39+
become: true

deploy/ansible/ballerine_playbook/roles/setup-ballerine/tasks/setup-ballerine.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
23
- name: Replace VITE URL for backoffice
34
lineinfile:
45
path: '~/ballerine/apps/backoffice-v2/.env.example'
@@ -33,16 +34,4 @@
3334
ansible.builtin.template:
3435
src: templates/Caddyfile.j2
3536
dest: "{{ install_dir }}/deploy/caddy/Caddyfile"
36-
when: vite_api_url != ""
37-
38-
- name: Deploy Ballerine up locally
39-
shell: docker-compose -f docker-compose-build.yml up -d
40-
args:
41-
chdir: "{{ install_dir }}/deploy"
42-
when: vite_api_url == ""
43-
44-
- name: Deploy Ballerine up remote
45-
shell: docker-compose -f docker-compose-build-https.yml up -d
46-
args:
47-
chdir: "{{ install_dir }}/deploy"
48-
when: vite_api_url != ""
37+
when: vite_api_url != ""

0 commit comments

Comments
 (0)