{"id":15430502,"url":"https://github.com/lenisha/vsts-terraform-ansible","last_synced_at":"2025-04-19T16:54:39.285Z","repository":{"id":116070944,"uuid":"131635608","full_name":"lenisha/vsts-terraform-ansible","owner":"lenisha","description":"VSTS Pipeline demonstrating Terraform and Ansible ","archived":false,"fork":false,"pushed_at":"2018-05-28T04:04:35.000Z","size":11878,"stargazers_count":11,"open_issues_count":0,"forks_count":37,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-18T06:16:05.398Z","etag":null,"topics":["ansible","spring-boot","terraform","vsts"],"latest_commit_sha":null,"homepage":"https://open.microsoft.com/2018/05/22/cicd-azure-terraform-ansible-vsts-java-springboot-app/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lenisha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-30T19:05:35.000Z","updated_at":"2022-01-24T16:13:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"bc782309-d8b7-46c2-8115-a40090c9d9fb","html_url":"https://github.com/lenisha/vsts-terraform-ansible","commit_stats":{"total_commits":46,"total_committers":2,"mean_commits":23.0,"dds":0.04347826086956519,"last_synced_commit":"fdb433aa3d8f17a1b0e411f09dd69fe05f37177c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenisha%2Fvsts-terraform-ansible","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenisha%2Fvsts-terraform-ansible/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenisha%2Fvsts-terraform-ansible/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenisha%2Fvsts-terraform-ansible/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lenisha","download_url":"https://codeload.github.com/lenisha/vsts-terraform-ansible/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249743261,"owners_count":21319085,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","spring-boot","terraform","vsts"],"created_at":"2024-10-01T18:16:44.902Z","updated_at":"2025-04-19T16:54:39.268Z","avatar_url":"https://github.com/lenisha.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Continuous Integration and Deployment using VSTS , Terraform and Ansible\n============\n\nThis repo is demontrating CI/CD Flow:\n- Uses VSTS Build to build SpringMusic App (gradle)\n- Uses VSTS Release to invoke Terraform to provision Infrastructure for the application (VMSS, LB, NSG)\n- Uses VSTS Release to invoke Ansible to install JDK, Tomcat 7 and SpringMusic App on provisioned VMs\n\n![Flow](./iac/CICD-Flow.PNG)\n\n## Terraform\nTerraform template is located at `iac/terraform`. It creates VM Scale Set based on RedHat 7.3 image in marketplace.\nVSTS uses Azure Storage backend to store state file.  Storage account and Container should be created before starting the build. (Defaults are in backend.tfvars)\n\n## Ansible\nAnsible playbook is located at `iac/ansible`. It uses `selinux` and `tomcat` roles to inctall and configure JDK, Tomcat 7 and deploy the application. \n\n\n## Spring Music Sample Application\n\n\nThis is a sample application for using database services on [Cloud Foundry](http://cloudfoundry.org) with the [Spring Framework](http://spring.io).\n\nThis application has been built to store the same domain objects in one of a variety of different persistence technologies - relational, document, and key-value stores. This is not meant to represent a realistic use case for these technologies, since you would typically choose the one most applicable to the type of data you need to store, but it is useful for testing and experimenting with different types of services on Cloud Foundry. \n\nThe application use Spring Java configuration and [bean profiles](https://spring.io/blog/2011/02/14/spring-3-1-m1-introducing-profile/) to configure the application and the connection objects needed to use the persistence stores. It also uses the [Spring Cloud Connectors](http://cloud.spring.io/spring-cloud-connectors/) library to inspect the environment when running on Cloud Foundry. See the [Cloud Foundry documentation](http://docs.cloudfoundry.org/buildpacks/java/spring-service-bindings.html) for details on configuring a Spring application for Cloud Foundry.\n\n## Running the application locally\n\nOne Spring bean profile should be activated to choose the database provider that the application should use. The profile is selected by setting the system property `spring.profiles.active` when starting the app.\n\nThe application can be started locally using the following command:\n\n~~~\n$ ./gradlew tomcatRun -Dspring.profiles.active=\u003cprofile\u003e\n~~~\n\nwhere `\u003cprofile\u003e` is one of the following values:\n\n* `in-memory` (no external database required)\n* `mysql`\n* `postgres`\n* `mongodb`\n* `redis`\n\nIf no profile is provided, `in-memory` will be used. If any other profile is provided, the appropriate database server\nmust be started separately. The application will use the host name `localhost` and the default port to connect to the database.\n\nIf more than one of these profiles is provided, the application will throw an exception and fail to start.\n\n## Running the application on Cloud Foundry\n\nWhen running on Cloud Foundry, the application will detect the type of database service bound to the application\n(if any). If a service of one of the supported types (MySQL, Postgres, Oracle, MongoDB, or Redis) is bound to the app, the\nappropriate Spring profile will be configured to use the database service. The connection strings and credentials\nneeded to use the service will be extracted from the Cloud Foundry environment.\n\nIf no bound services are found containing any of these values in the name, then the `in-memory` profile will be used.\n\nIf more than one service containing any of these values is bound to the application, the application will throw an\nexception and fail to start.\n\nAfter installing the 'cf' [command-line interface for Cloud Foundry](http://docs.cloudfoundry.org/cf-cli/), targeting a Cloud Foundry instance, and logging in, the application can be built and pushed using these commands:\n\n~~~\n$ ./gradlew assemble\n\n$ cf push\n~~~\n\nThe application will be pushed using settings in the provided `manifest.yml` file. The output from the command will show the URL that has been assigned to the application.\n\n### Creating and binding services\n\nUsing the provided manifest, the application will be created without an external database (in the `in-memory` profile).\nYou can create and bind database services to the application using the information below.\n\n#### System-managed services\n\nDepending on the Cloud Foundry service provider, persistence services might be offered and managed by the platform. These\nsteps can be used to create and bind a service that is managed by the platform:\n\n~~~\n# view the services available\n$ cf marketplace\n# create a service instance\n$ cf create-service \u003cservice\u003e \u003cservice plan\u003e \u003cservice name\u003e\n# bind the service instance to the application\n$ cf bind-service \u003capp name\u003e \u003cservice name\u003e\n# restart the application so the new service is detected\n$ cf restart\n~~~\n\n#### User-provided services\n\nCloud Foundry also allows service connection information and credentials to be provided by a user. In order for the\napplication to detect and connect to a user-provided service, a single `uri` field should be given in the credentials\nusing the form `\u003cdbtype\u003e://\u003cusername\u003e:\u003cpassword\u003e@\u003chostname\u003e:\u003cport\u003e/\u003cdatabasename\u003e`.\n\nThese steps use examples for username, password, host name, and database name that should be replaced with real values.\n\n~~~\n# create a user-provided Oracle database service instance\n$ cf create-user-provided-service oracle-db -p '{\"uri\":\"oracle://root:secret@dbserver.example.com:1521/mydatabase\"}'\n# create a user-provided MySQL database service instance\n$ cf create-user-provided-service mysql-db -p '{\"uri\":\"mysql://root:secret@dbserver.example.com:3306/mydatabase\"}'\n# bind a service instance to the application\n$ cf bind-service \u003capp name\u003e \u003cservice name\u003e\n# restart the application so the new service is detected\n$ cf restart\n~~~\n\n#### Changing bound services\n\nTo test the application with different services, you can simply stop the app, unbind a service, bind a different\ndatabase service, and start the app:\n\n~~~\n$ cf unbind-service \u003capp name\u003e \u003cservice name\u003e\n$ cf bind-service \u003capp name\u003e \u003cservice name\u003e\n$ cf restart\n~~~\n\n## Courses using this application.\n\n`Note`: When updating this application please make sure the corresponding instructions are updated within the following dependent courses. The instructions for these labs may not change but please review before pushing application to production with this [pipeline](http://concourse.enablement.pivotal.io/pipelines/spring-music-war).\n\n- [pivotal-cloud-foundry-developer](https://github.com/pivotal-education/pivotal-cloud-foundry-developer):\n\n#### Database drivers\n\nDatabase drivers for MySQL, Postgres, MongoDB, and Redis are included in the project. To connect to an Oracle database,\nyou will need to download the appropriate driver (e.g. from http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html?ssSourceSiteId=otnjp),\nadd the driver .jar file to the `src/main/webapp/WEB-INF/lib` directory in the project, and re-build the\napplication .war file using `./gradlew assemble`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flenisha%2Fvsts-terraform-ansible","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flenisha%2Fvsts-terraform-ansible","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flenisha%2Fvsts-terraform-ansible/lists"}