· 5 years ago · Nov 08, 2019, 07:44 AM
1# Gitlab
2# На этом шаге деплоится AIO стенд
3deploy_aio:
4 stage: deploy
5 when: manual
6 environment:
7 name: ${CI_COMMIT_REF_SLUG}
8 url: http://${CI_COMMIT_REF_SLUG}.dev.domain.com
9 before_script:
10 - git clone git@gitlab.com:robot_robert/abagy-deploy.git
11 - cd abagy-deploy
12 script:
13 - ansible-playbook --diff -i inventories/aio/hosts.aio-custom.ini playbooks/deploy-aio.yml
14 --private-key=~/.ssh/rwc_deploy
15 -u deploy
16 -e "debug=false"
17 -e "default_docker_image_tag=${CI_COMMIT_REF_SLUG}"
18 -e "host_name=${AIO_HOST}"
19 only:
20 - merge_requests
21 extends: .shell-builders
22
23================================================
24# Ansible, но можешь через баш делать
25
26---
27- name: "Step 1: Provision AIO"
28 hosts: localhost
29 gather_facts: false
30 connection: local
31 tasks:
32 - name: Collect info
33 terraform:
34 project_path: "{{ tf_project_path }}"
35 state: "{{ vm_state }}"
36 force_init: true
37 variables:
38 host_name: "{{ host_name }}"
39 variables_file: "{{ tf_variables_file }}"
40 backend_config:
41 key: "development/{{ host_name }}.tfstate"
42 access_key: "{{ minio_terraform_access_key }}"
43 secret_key: "{{ minio_terraform_secret_key }}"
44 register: create_vm
45 tags:
46 - destroy
47
48 - name: Print terraform output
49 debug:
50 var: create_vm
51 tags:
52 - destroy
53
54 - name: Add host to app group
55 add_host:
56 hostname: "{{ create_vm.outputs.server_name.value }}"
57 ansible_ssh_host: "{{ create_vm.outputs.server_ip.value }}"
58 groups:
59 - app
60 delegate_to: localhost
61 when: vm_state == "present"
62
63- name: "Step 3: Deploy application"
64 hosts: app
65 become: true
66 roles:
67 - { role: robocloud, when: vm_state == "present" }
68
69
70=========================
71
72# hosts.aio-custom.ini
73[app]