Skip to content

Commit de2ef91

Browse files
committed
task: add prod.inventory and prod.yml to allow to run Ansible from CI
Part of #1125 Required for #1631 [skip ci]
1 parent b5f858d commit de2ef91

File tree

4 files changed

+73
-2
lines changed

4 files changed

+73
-2
lines changed

.github/workflows/provision-by-ansible.yml

+27
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,33 @@ jobs:
3333
# See https://docs.ansible.com/ansible/2.10/installation_guide/intro_installation.html#installing-devel-from-github-with-pip
3434
run: python3 -m pip install --user https://github.com/ansible/ansible/archive/refs/tags/v2.10.17.tar.gz
3535

36+
- name: Show ansible version
37+
run: ansible --version
38+
39+
- name: Decrypt ansible files
40+
working-directory: infra/vagrant
41+
env:
42+
# https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
43+
VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD }}
44+
run: |
45+
printf '%s' "$VAULT_PASSWORD" >vault-pass.txt
46+
47+
for FILENAME in provisioning/vars/prod.yml; do
48+
echo "Decrypting ${FILENAME}.enc to $FILENAME"
49+
ansible-vault decrypt \
50+
--vault-password-file vault-pass.txt \
51+
--output "$FILENAME" \
52+
"${FILENAME}.enc"
53+
done
54+
3655
- name: Run ansible in syntax check mode
56+
working-directory: infra/vagrant
3757
run: ansible-playbook provisioning/prod.yml -i provisioning/prod.inventory --syntax-check
58+
59+
- name: Cleanup
60+
if: always()
3861
working-directory: infra/vagrant
62+
run: |
63+
for FILE in vault-pass.txt provisioning/vars/prod.yml; do
64+
[ ! -f "$FILE" ] || rm -fv "$FILE"
65+
done

.gitignore

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ src/main/frontend/node_modules/
2121
# Vagrant related files
2222
.vagrant/
2323
infra/vagrant/provisioning/vagrant.retry
24-
infra/vagrant/provisioning/prod.inventory
2524
infra/vagrant/provisioning/vars/prod.yml
2625
infra/vagrant/provisioning/roles/php-coder.oraclejdk/
2726
infra/vagrant/provisioning/roles/php-coder.nginx/
@@ -39,7 +38,10 @@ infra/terraform/terraform.tfstate.backup
3938
infra/docker/application-prod.properties
4039
infra/docker/mysql_backup_mystamps.sql.gz
4140

42-
# created by src/main/scripts/ci/deploy.sh or .github/workflows/provision-by-terraform.yml
41+
# created by:
42+
# src/main/scripts/ci/deploy.sh
43+
# .github/workflows/provision-by-ansible.yml
44+
# .github/workflows/provision-by-terraform.yml
4345
vault-pass.txt
4446

4547
# created by src/main/scripts/ci/deploy.sh
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Ansible inventory file
2+
# See: https://docs.ansible.com/ansible/2.10/user_guide/intro_inventory.html
3+
4+
[prod]
5+
my-stamps.ru ansible_host=46.101.232.167
6+
7+
[all:vars]
8+
ansible_user=coder
9+
ansible_ssh_private_key_file=/Users/coder/.ssh/mystamps_rsa
10+
11+
# https://docs.ansible.com/ansible/2.10/reference_appendices/python_3_support.html#using-python-3-on-the-managed-machines-with-commands-and-playbooks
12+
# https://docs.ansible.com/ansible/2.10/reference_appendices/interpreter_discovery.html
13+
ansible_python_interpreter=/usr/bin/python3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
$ANSIBLE_VAULT;1.1;AES256
2+
31383633616337333536623830663864613437393030393034323836633239623463383735313363
3+
3638316534376236666238343763626533376135633362660a373965346438346266653163613830
4+
63323334323330623363316438333133306364356639346464353663313730613130353461636237
5+
3736643233626662310a383133353338303335623333316331306139323334343565316333633030
6+
62323966656263373736353464326662356465363062356239373238663062396263306236633232
7+
35343165323639356637653030326263386235653965613438326566373739663938333730623765
8+
39343837393032303735386636363137323839626537303339303139633830666239366135393462
9+
35326163326666653433303536656633383831303533303236643333356461636361376364396338
10+
38366331396561393737313636623230666531363966636332343763363061366161666135336434
11+
66323038376137356163326139643338663330663535633938376163653163373039353165363135
12+
31333264633663306563346663336535616333626237356436626138653234326333633932666232
13+
38303761363464323164393830383261636436653962396131653833323866653364313338313836
14+
39316362653534326166393562396237633863663835646636343930326139646461343632613764
15+
33626634613736363664316134333365653632393537616139383864316662373839653262386263
16+
32616364616437343133393930613636396663383962313331353139353338306335623831316630
17+
61313765366339643537313835613134393363646539393037393665303863323966376565356335
18+
34356463333761303231333539653935633535353061313865303431393634313139386534363266
19+
32633866363164663461323834326131633431393663316237623630313034643830663434333631
20+
30666139393634616231393839303135363863643261353866613236633435353164396666386533
21+
38333433336364666139306666326437396336363439353032326137396139386335326336316132
22+
61343862353035633561613231383134313935346361393232313733333566336531396337343639
23+
63356631346238323838343561663265396264633533653836323131373835633064623961363335
24+
36306531356338353035383062363330336337343362333663396366393263346630363637333365
25+
35613037373139313966613534386664646431656239363465666166653166363630396166656632
26+
32386635333761393730393237663763386534386162313166656564343434643066613536633634
27+
61653365326162613363653431333433626562636462353537643739316236366535386463653830
28+
35323563353837386533663732323438656637613237366261303335376463646262323866323230
29+
34323731343430323236

0 commit comments

Comments
 (0)