Welcome to a new era of Microservice Multicloud Adaptive Payment Opensource Platform which compliant PCI DSS as SaaS product.
-
Requirements:
- New domain or subdomain which ready to be placed a cloud nameservers which we bootstrap.
- Alicloud / Vsphere infrastructure.
- Complete fill requirement settings in inventories which need for bootstrap.
- Install ansible alicloud modules via pip, -
{{ ansible_root }}/requirements.yml
-
Pre defined information:
-
We have two types of inventories -
I. Dynamic
bootstrap inventory
prefilled for create the instances -inventories/0z-cloud/products
.II. Target Inventory after
bootstrap inventory
which contains settings needed after bootstrap the instances -inventories/products
. -
We have types of clouds backends
{{ cloud_type }}
, now it is:-
alicloud
-
vsphere
-
do (digitalocean)
-
azure
-
aws
-
bare (baremethal)
-
google
-
-
We have a
products
which have environments{{ ansible_environment }}
, likedevelop/stage/production
. -
We have three types and places for
group_vars
, - spaces that contain main or specific hosts groups settings.I. Root variables:
{{ ansible_root }}/group_vars
and{{ ansible_root }}/group_vars/products/{{ product_name }}
II. Cloud bootstrap variables, which needed to initial create the cloud instances:
{{ ansible_root }}/inventories/0z-cloud/products/{{ cloud_type }}/{{ product_name }}/{{ ansible_environment }}/bootstrap_vms/group_vars/all.yml
III. Variables in
Target Inventory
needed for run playbooks after the creation of the cloud instances:{{ ansible_root }}/inventories/products/{{ product_name }}/{{ ansible_environment }}/group_vars
-
-
Fill the access keys from example, for able project
in run setup
access to your cloud infrastructure:-
Be careful - you need to prevent sensitive security data from push to repository, you must add them to
.gitignore
-
For
alicloud
move{{ ansible_root }}/group_vars/products/{{ product_name }}/alicloud.yml.example
to{{ ansible_root }}/group_vars/products/{{ product_name }}/alicloud.yml
and fill settings got from alicloud console. -
For
vsphere
move{{ ansible_root }}/group_vars/products/{{ product_name }}/vsphere.yml.example
to{{ ansible_root }}/group_vars/products/{{ product_name }}/vsphere.yml
and fill settings got from vsphere console. -
For main settings move
{{ ansible_root }}/group_vars/products/{{ product_name }}/main.yml.example
to{{ ansible_root }}/group_vars/products/{{ product_name }}/main.yml
and fill extra settings. -
You can dynamically attach some specific dictionaries with settings in !_root_playbooks for some type of cloud:
- name: Load groupvars/product global shared settings include_vars: group_vars/products/{{ ansible_product }}/{{ item }}.yml with_items: - vsphere - main - name: Load groupvars/product global shared settings include_vars: group_vars/products/{{ ansible_product }}/{{ ansible_environment }}/{{ item }}.yml with_items: - attached - main
-
-
Information about the run process:
-
When all settings filled correctly, you can run the wrapper, to get a list of all commands needed for run step by step:
{{ ansible_root }}/\!_stand-minimal.sh
-
For wrapper you need to provide settings:
{{ ansible_root }}/\!_stand-minimal.sh {{ ansible_environment }} {{ product_name }} USERNAME PASS {{ NOWAIT }} {{ TYPE_OF_RUN }} {{ cloud_type }}
-
-
A little example of commands which ran step by step for setup a simple cloud, got by wrapper.
-
Creating VMs:
ansible-playbook -i inventories/0z-cloud/products/types/\!_alicloud/vortex/production/bootstrap_vms/ ./\!_root_playbooks/alicloud/bootstrap-ng.yml -e ansible_product=vortex --ask-vault-pass
-
Run convertation from
0z-cloud inventory
toTarget inventory
:{{ ansible_root }}/!_root_playbooks/cloud_regen.sh production vortex alicloud cloud_connection_type
-
Run initial DNS configuration playbook:
ansible-playbook -i inventories/products/vortex/production/ playbook-library/!_bootstrap/dns.yml -e HOSTS=ids-keepalive-servers -u vortex --become-user root --become -e ansible_become_pass='1235' -e ansible_ssh_pass='1235'
ansible-playbook -i inventories/products/vortex/production/ playbook-library/!_bootstrap/systemd_resolved.yml -u vortex --become-user root --become -e ansible_become_pass='1235' -e ansible_ssh_pass='1235'
-
Adding the inventory users and public keys for access to instances (developers/admins/etc):
ansible-playbook -i inventories/products/vortex/production/ playbook-library/system/ssh.yml -e HOSTS=all -u vortex --become-user root --become -e ansible_become_pass='1235' -e ansible_ssh_pass='1235' --tags add_user
-
Running the Consul cluster installation playbook:
ansible-playbook -i inventories/products/vortex/production/ playbook-library/cloud/consul/!_consul_cloud_playbook.yml -e HOSTS=all -u vortex --become-user root --become -e ansible_become_pass='1235' -e ansible_ssh_pass='1235' -e consul_upgrade=true
-
Creating the cloud persistent storages for each needed that hosts groups:
ansible-playbook -i inventories/products/vortex/production/ playbook-library/storage/glusterfs-cluster.yml -e GLUSTERFS_CLUSTER_HOSTS=cloud-bind-frontend-persistence-dns-glusterfs-storage -u vortex --become-user root --become -e ansible_become_pass='1235' -e ansible_ssh_pass='1235'
ansible-playbook -i inventories/products/vortex/production/ playbook-library/storage/glusterfs-cluster.yml -e GLUSTERFS_CLUSTER_HOSTS=bind-master-glusterfs -u vortex --become-user root --become -e ansible_become_pass='1235' -e ansible_ssh_pass='1235'
-
Installing docker subsystem:
ansible-playbook -i inventories/products/vortex/production/ playbook-library/cloud/docker/docker-install-auto-cloud.yml -e HOSTS=all -u vortex --become-user root --become -e ansible_become_pass='1235' -e ansible_ssh_pass='1235'
-
Installing CoreDNS cloud forwarder:
ansible-playbook -i inventories/products/vortex/production/ playbook-library/!_bootstrap/core-dns.yml -e HOSTS=cloud-bind-frontend-dns -u vortex --become-user root --become -e ansible_become_pass='1235' -e ansible_ssh_pass='1235'
-
Installing DNS Backend service for publishing services DNS records to the Internet:
ansible-playbook -i inventories/products/vortex/production/ playbook-library/!_bootstrap/dns-backend.yml -e HOSTS=master-bind-master-backend -u vortex --become-user root --become -e ansible_become_pass='1235' -e ansible_ssh_pass='1235'
-
Obtaining wildcard certificate for cloud domain:
ansible-playbook -i inventories/products/vortex/production/ playbook-library/!_bootstrap/letsencrypt-pacemaker.yml -e HOSTS=master-bind-master-backend -u vortex --become-user root --become -e ansible_become_pass='1235' -e ansible_ssh_pass='1235'
-
Creation of the Docker Swarm Cluster where to after to be deploy stack of applications:
ansible-playbook -i inventories/products/vortex/production/ playbook-library/cloud/swarm/swarm-cluster.yml -e SWARM_MASTERS=swarm-cluster -u vortex --become-user root --become -e ansible_become_pass='1235' -e ansible_ssh_pass='1235' -e leave_cluster=true
-
Deploy nginx frontend role, which provides proxy to backends:
ansible-playbook -i inventories/vortex/production/ playbook-library/cloud/nginx/nginx-frontend-ng.yml -e HOSTS=nginx-frontend -u vortex --become-user root --become -e ansible_become_pass=1235 -e ansible_ssh_pass=1235
-
Profit: Cloud initialization done, now we can deploy the applications.
-
-
Basic Directory Structure:
/root_dir/ | |-/ansible | |-/services | |-/docs | |-/dockerfiles | /.gitlab-ci.yml
-
Build process basic:
-
We have three basic environments, its -
development stage production
-
Deploy to each environment start automatically via Gitlab CI by .gitlab-ci.yml file:
-
when we push
any
branch deploy starts todevelopment environment
. -
when we update and push commits to branch with name
develop
deploy starts tostage environment
. -
when we update and push commits to
master
branch deploy starts toproduction environment
.
-
-
Deploy and build process controlled by script:
/root_dir/ansible/!_all_service_deployer.sh
-
Build script basic work:
-
The Script takes applications and services from each dirs, as example
/root_dir/services/{{ service_name }} /root_dir/docs/{{ service_name }} /root_dir/services/{{ service_name }}
-
Script build services and push to Gitlab Docker Registry
-
Script generates the docker-stack file for deploy docker swarm stack
-
Script deploys updated applications and services from built images got from the docker registry.
-
-
-
-
For each public service you must have a nginx configuration and public certificates, this process controlled by the wrapper:
/root_dir/ansible/!_0z-nginx_acme_helper.sh
-
Wrapper checks the DNS configuration
-
Wrapper run the
playbook-library/!_bootstrap/letsencrypt-pacemaker.yml
for each public domain and service which declared in:/root_dir/ansible/inventories/products/$product/$inventory/group_vars/all.yml
aspublic_consul_domain
/root_dir/ansible/!_0z-nginx_acme_helper.sh
asdeclare prefixes_list=( )
-
Wrapper sync obtained certificates from DNS backend service to Nginx frontend service.
-
In last step wrapper update nginx configuration via run a playbook
/root_dir/ansible/playbook-library/cloud/nginx/nginx-frontend-ng.yml
-