From 8cf02acd8d111f4f904c6b849f60e11dfc2dc268 Mon Sep 17 00:00:00 2001 From: abikouo Date: Thu, 3 Aug 2023 17:47:51 +0200 Subject: [PATCH] add documentation for collection playbooks --- README.md | 5 ++- playbooks/VALIDATE_DEPLOYMENT.md | 8 ++++ playbooks/VMSS_MIGRATE.md | 54 ++++++++++++++++++++++++ playbooks/WEBAPP.md | 65 +++++++++++++++++++++++++++++ playbooks/WEBAPP_CONTAINER.md | 70 ++++++++++++++++++++++++++++++++ playbooks/webapp.yml | 2 +- playbooks/webapp_container.yml | 2 +- 7 files changed, 203 insertions(+), 3 deletions(-) create mode 100644 playbooks/VALIDATE_DEPLOYMENT.md create mode 100644 playbooks/VMSS_MIGRATE.md create mode 100644 playbooks/WEBAPP.md create mode 100644 playbooks/WEBAPP_CONTAINER.md diff --git a/README.md b/README.md index b733a50..45d9b82 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,10 @@ Name | Description ### Playbooks Name | Description --- | --- -cloud.azure_ops.webapp|A playbook to create a webapp on Azure. +[cloud.azure_ops.webapp](https://github.com/redhat-cop/cloud.azure_ops/blob/main/playbooks/WEBAPP.md)|A playbook to deploy a web application on azure using virtual machines. +[cloud.azure_ops.webapp_container](https://github.com/redhat-cop/cloud.azure_ops/blob/main/playbooks/WEBAPP_CONTAINER.md)|A playbook to deploy a web application on azure using containers. +[cloud.azure_ops.vmss_migrate](https://github.com/redhat-cop/cloud.azure_ops/blob/main/playbooks/VMSS_MIGRATE.md)|A playbook to migrate virtual machines of a web application from one azure region to another region. +[cloud.azure_ops.validate_deployment](https://github.com/redhat-cop/cloud.azure_ops/blob/main/playbooks/VALIDATE_DEPLOYMENT.md)|A playbook to validate successful deployment of web application URL. ## Installation and Usage diff --git a/playbooks/VALIDATE_DEPLOYMENT.md b/playbooks/VALIDATE_DEPLOYMENT.md new file mode 100644 index 0000000..98f49fa --- /dev/null +++ b/playbooks/VALIDATE_DEPLOYMENT.md @@ -0,0 +1,8 @@ +## cloud.azure_ops.validate_deployment playbook + +A playbook to validate successful deployment of a web application. + +Variables +-------------- + +* **azure_app_url**: (Required) URL of the Web application. \ No newline at end of file diff --git a/playbooks/VMSS_MIGRATE.md b/playbooks/VMSS_MIGRATE.md new file mode 100644 index 0000000..92cc86b --- /dev/null +++ b/playbooks/VMSS_MIGRATE.md @@ -0,0 +1,54 @@ +## cloud.azure_ops.vmss_migrate playbook + +A playbook to migrate virtual machines of a web application from one Azure region to another region. + +Variables +-------------- + +###### Common +-------------- + +* **source_resource_group**: The origin resource group. Should not be equal to **destination_resource_group**. Default: `src_rg` +* **source_region**: The origin Azure region. Default: `eastus` +* **destination_resource_group**: The destination resource group. Should not be equal to **source_resource_group**. Default: `dst_rg` +* **destination_region**: The destination Azure region. Default: `canadacentral` + + +-------------- +###### Networking +-------------- + +* **azure_vnet_address_prefixes_cidr**: The virtual network CIDR address prefixes. Default: `['10.1.0.0/16']` +* **azure_subnet_address_prefixes_cidr**: The subnet CIDR address prefixes. Default: `10.1.0.0/24` + +-------------- +###### Virtual machines +-------------- +* **azure_vm_name**: Virtual machine scaleset name prefix, the name of the scaleset will be `{{ azure_vm_name }}ss`. Default: `webapp-vm-` +* **azure_vm_user**: Virtual machine user. Default: `ansible` +* **azure_vm_user_password**: Virtual machine user password. Default: `4fB5In3ueO7,` + +-------------- +###### PostgreSQL +-------------- +* **azure_postgresql_name**: The name of the PostgreSQL server. Default: `{{ azure_resource_group | replace('_', '-') }}-dbserver` +* **azure_postgresql_admin_username**: The database server admin user. Default: `ansible` +* **azure_postgresql_admin_password**: The database server admin user password. Default: `4fB5In3ueO7,` +* **azure_postgresql_database_instances**: The list of database instances. Default: `[{'name': 'pyapp', 'charset': 'UTF8'}]` +* **azure_postgresql_firewall_rules**: The database firewall rules. Default: `[{'name': 'allow_all', 'start_ip_address': '0.0.0.0', 'end_ip_address': '255.255.255.255'}]` + +-------------- +###### Web application +-------------- + +* **py_application**: Object used to provide details for the web application. Contains the following: + - * **env**: The python flask application environment. Default: `development` + - * **admin_user**: The web application admin user. Default: `admin` + - * **admin_password**: The web application admin user password: Default: `admin` + - * **docker_image**: The name of the Docker image to build. Default: `pywebapp` + - * **docker_dir**: Path on virtual machine where Docker files will be downloaded. Default: `/app/pyapp` + - * **container_name**: The name of the container to start on the VM. Default: `myapp-container` + +* **application_force_init**: Whether to force application initialization, this will delete existing data from the databse. Default: `false` +* **application_src**: Remote repository application source code. Default: `https://github.com/abikouo/webapp_pyflask_demo.git` +* **playbook_number_forks**: number of parallel fork to use to deploy application into VM. Default: `15` diff --git a/playbooks/WEBAPP.md b/playbooks/WEBAPP.md new file mode 100644 index 0000000..dca5b0f --- /dev/null +++ b/playbooks/WEBAPP.md @@ -0,0 +1,65 @@ +## cloud.azure_ops.webapp playbook + +A playbook to deploy a web application on Azure using virtual machines. + +Variables +-------------- + +###### Common +-------------- + +* **azure_resource_group**: (Required) Resource group on/from which the web application resources will reside. +* **azure_region**: An Azure location for the resources. Default: `eastus` +* **azure_tags**: Dictionary of string:string pairs to assign as metadata to the resources. + Default: `{'application': 'python-demo-webapp-for-ansible-cloud-team'}` + +-------------- +###### Networking +-------------- + +* **azure_virtual_network**: The name of the virtual network for VMs. Default: `{{ azure_resource_group }}-vnet` +* **azure_vnet_address_prefixes_cidr**: The virtual network CIDR address prefixes. Default: `['10.1.0.0/16']` +* **azure_subnet**: The name of the subnet inside the virtual network. Default: `{{ azure_resource_group }}-subnet` +* **azure_subnet_address_prefixes_cidr**: The subnet CIDR address prefixes. Default: `10.1.0.0/24` +* **azure_security_group**: The network security group name. Default: `{{ azure_resource_group }}-nsg` +* **azure_load_balancer**: Object used to provide details for a load balancer. Contains the following: + - **name**: Name of the load balancer. Default: `{{ azure_resource_group }}-lb` + - **public_ip_name**: Name of load balancer's public ip. Default: `{{ azure_resource_group }}-lb-public-ip` + - **backend_address_pool**: Name of backend address pools where network interfaces can be attached. Default: `{{ azure_resource_group }}-vm-pool` + - **domain_name**: Load balancer domain name. + +-------------- +###### Virtual machines +-------------- +* **azure_vm_name**: Virtual machine scaleset name prefix, the name of the scaleset will be `{{ azure_vm_name }}ss`. Default: `webapp-vm-` +* **azure_vm_user**: Virtual machine user. Default: `ansible` +* **azure_vm_user_password**: Virtual machine user password. Default: `4fB5In3ueO7,` +* **azure_vm_image**: The image used to build the VM. See [azure.azcollection.azure_rm_virtualmachine](https://github.com/ansible-collections/azure/blob/5df571fbbb4cd83ad98b143157ae947f1d15b2d9/plugins/modules/azure_rm_virtualmachine.py#L136-L141). Default: `{'offer': 'RHEL', 'publisher': 'RedHat', 'sku': '7-LVM', 'version': 'latest'}` +* **azure_vm_size**: The Azure VM size. Default: `Standard_A2` +* **azure_bastion_vm_size**: The Azure VM size for the bastion VM. Default: `Standard_A1_v2` +* **azure_number_vm**: The number of VM on the virtual machine scaleset. Default: `3` + +-------------- +###### PostgreSQL +-------------- +* **azure_postgresql_name**: The name of the PostgreSQL server. Default: `{{ azure_resource_group | replace('_', '-') }}-dbserver` +* **azure_postgresql_admin_username**: The database server admin user. Default: `ansible` +* **azure_postgresql_admin_password**: The database server admin user password. Default: `4fB5In3ueO7,` +* **azure_postgresql_database_instances**: The list of database instances. Default: `[{'name': 'pyapp', 'charset': 'UTF8'}]` +* **azure_postgresql_firewall_rules**: The database firewall rules. Default: `[{'name': 'allow_all', 'start_ip_address': '0.0.0.0', 'end_ip_address': '255.255.255.255'}]` + +-------------- +###### Web application +-------------- + +* **py_application**: Object used to provide details for the web application. Contains the following: + - * **env**: The python flask application environment. Default: `development` + - * **admin_user**: The web application admin user. Default: `admin` + - * **admin_password**: The web application admin user password: Default: `admin` + - * **docker_image**: The name of the Docker image to build. Default: `pywebapp` + - * **docker_dir**: Path on virtual machine where Docker files will be downloaded. Default: `/app/pyapp` + - * **container_name**: The name of the container to start on the VM. Default: `myapp-container` + +* **application_force_init**: Whether to force application initialization, this will delete existing data from the database. Default: `false` +* **application_src**: Remote repository application source code. Default: `https://github.com/abikouo/webapp_pyflask_demo.git` +* **playbook_number_forks**: number of parallel fork to use to deploy application into VM. Default: `15` diff --git a/playbooks/WEBAPP_CONTAINER.md b/playbooks/WEBAPP_CONTAINER.md new file mode 100644 index 0000000..77fd955 --- /dev/null +++ b/playbooks/WEBAPP_CONTAINER.md @@ -0,0 +1,70 @@ +## cloud.azure_ops.webapp_container playbook + +A playbook to deploy a web application on Azure using containers. + +Variables +-------------- + +###### Common +-------------- + +* **azure_resource_group**: (Required) Resource group on/from which the web application resources will reside. +* **azure_region**: An Azure location for the resources. Default: `eastus` +* **migrate_app**: Flag for migrating from VM / creating from scratch. Default: `false` + +-------------- +###### Networking +-------------- + +* **azure_virtual_network**: The name of the virtual network for VMs. Default: `{{ azure_resource_group }}-vnet` +* **azure_vnet_address_prefixes_cidr**: The virtual network CIDR address prefixes. Default: `['10.1.0.0/16']` +* **azure_subnet**: The name of the subnet inside the virtual network. Default: `{{ azure_resource_group }}-subnet` +* **azure_subnet_address_prefixes_cidr**: The subnet CIDR address prefixes. Default: `10.1.0.0/24` +* **azure_security_group**: The network security group name. Default: `{{ azure_resource_group }}-nsg` +* **azure_load_balancer**: Object used to provide details for a load balancer. Contains the following: + - **name**: Name of the load balancer. Default: `{{ azure_resource_group }}-lb` + - **public_ip_name**: Name of load balancer's public ip. Default: `{{ azure_resource_group }}-lb-public-ip` + - **backend_address_pool**: Name of backend address pools where network interfaces can be attached. Default: `{{ azure_resource_group }}-vm-pool` + +-------------- +###### Container +-------------- +* **azure_app_force_update**: Whether to force update of existing instance when creating container instance. Default: `false` +* **azure_vm_os**: Container instance OS type. Default: `Linux` + +-------------- +###### PostgreSQL +-------------- +* **azure_postgresql_name**: The name of the PostgreSQL server. Default: `{{ azure_resource_group | regex_replace('[^a-zA-Z0-9]', '-') }}-dbserver` +* **azure_postgresql_admin_username**: The database server admin user. Default: `ansible` +* **azure_postgresql_admin_password**: The database server admin user password. Default: `4fB5In3ueO7,` +* **azure_postgresql_database_instances**: The list of database instances. Default: `[{'name': 'pyapp', 'charset': 'UTF8'}]` + +-------------- +###### Web application +-------------- + +* **azure_app_image**: Application Docker image. Default: `quay.io/jtorcass/pywebapp` +* **azure_app_container_name**: Application container name: Default: `{{ azure_resource_group | regex_replace('[^a-zA-Z0-9]', '-') }}-container` +* **azure_app_mem**: Application memory. Default: `1` +* **azure_app_ports**: Application ports: Default: `[5000]` +* **azure_app_env_vars**: Application environment variables. + Default: + ```yaml + - name: FLASK_APP + value: /app/pyapp + - name: FLASK_ENV + value: development + - name: DATABASE_HOST + value: "{{ azure_postgresql_name }}" + - name: DATABASE_INSTANCE + value: "{{ azure_postgresql_database_instances[0].name }}" + - name: DATABASE_USER + value: "{{ azure_postgresql_admin_username }}" + - name: DATABASE_PASSWORD + value: "{{ azure_postgresql_admin_password }}" + - name: ADMIN_USER + value: admin + - name: ADMIN_PASSWORD + value: admin + ``` \ No newline at end of file diff --git a/playbooks/webapp.yml b/playbooks/webapp.yml index f636e65..ee29770 100644 --- a/playbooks/webapp.yml +++ b/playbooks/webapp.yml @@ -1,5 +1,5 @@ --- -- name: Bootstrap a web app application using azure collection +- name: Bootstrap a web app application using Azure collection hosts: localhost gather_facts: false diff --git a/playbooks/webapp_container.yml b/playbooks/webapp_container.yml index 53f84b8..28fd9eb 100644 --- a/playbooks/webapp_container.yml +++ b/playbooks/webapp_container.yml @@ -1,5 +1,5 @@ --- -- name: Deploy existing python app to container instance on azure +- name: Deploy existing python app to container instance on Azure hosts: localhost gather_facts: false