Здравствуй, Гость!
Вход | Регистрация
  • Страница 3 из 3
  • «
  • 1
  • 2
  • 3
Форум » Assassin's Creed: Общее » Книги и комиксы » Общая тема по литературе AC (Обсуждение)
Общая тема по литературе AC
Сообщение #41 | 18.05.2021, 18:06
Terraform azure devops - Kabrinskiy Eduard

<h1>Terraform azure devops</h1>
<p>[youtube]</p>
Terraform azure devops <a href="http://remmont.com">Current national news</a> Terraform azure devops
<h1>Infrastructure Automation with Terraform and Azure DevOps Pipeline Templates</h1>
<p style="clear: both"> <img style="float: left; margin: 0 10px 5px 0;" src="https://csprodstorage001.blob.core.windows.net/contributors/luke.jpg" />Luke Orellana on January, 06, 2020</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/images/terraform-azure.png" /></p>
<p>Infrastructure as Code is considered a best practice when managing infrastructure in the cloud. Tools like Terraform are becoming increasingly popular due to their ease of use and multi cloud nature. However, adopting the Infrastructure as Code model can become hectic and unmanageable if not organized strategically.</p>
<p>With designing any automated process, simplicity is key to creating long lasting solutions. In Azure DevOps, one way of simplifying code for Terraform configurations is by using pipeline templates to represent our infrastructure.</p>
<p>Each value in the template parameters is used to customize our configuration which is then built dynamically during the build pipeline. We can go from the traditional repository structure of storing our Terraform configuration files in folders to representing our infrastructure with pipeline template parameters:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/TraditionalvsSimple.png" /></p>
<p>Structuring our source code repositories this way allow us to scale our solution much easier and provides some of the following benefits:</p>
<p><ul>
<li>No more one-off changes can be made to Terraform configuration files since all configurations are built dynamically during the build pipeline and will all be the same. This prevents issues where team members are making changes to one system?s Terraform configuration causing us to have separate one-off configurations to maintain.</li>
<li>We can now separate our Terraform code from the team that deploys the configurations. All the Terraform modules and files are stored in another repository which we can limit access to and allow just our Terraform team to manage them.</li>
<li>Change tracking of infrastructure resources is much more simplified now since we are just looking at template parameter value changes in a single file.</li>
<li>Each deployment is going to be more consistent since we are using the same base Terraform configurations in each deployment. This also allows us to treat our Terraform configurations as cattle.</li>
</ul>
</p>
<p>In this guide, we will use the Azure DevOps Demo Generator to import an Azure DevOps project. This project has been pre-configured to deploy Azure Container Instances with Terraform using pipeline templates as code. We will deploy some resources to our Azure subscription and review the innerworkings of this concept.</p>
<h2>Prerequisites</h2>
<p>Before you begin this guide you?ll need the following:</p>
<p><ul>
<li>An Azure Subscription, you can get started with a free account.</li>
<li>An Azure DevOps Organization. The basic plan is free for the first 5 users.</li>
</ul>
</p>
<h2>Step 1 ? Importing the Project with Azure DevOps Demo Generator</h2>
<p>First, we are going to import an Azure DevOps template project into our Azure DevOps organization. This will allow us to get started as fast as possible. To get started, navigate to the Azure DevOps Demo Generator website.</p>
<p>Sign in with your Azure DevOps account. Select <strong>Accept</strong> to authorize the Azure DevOps Demo Generator application to access your account. Now we are ready to import our template. Select <strong>Choose Template</strong>:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/ChooseTemplate.png" /></p>
<p>A pop-up window will appear, choose the <strong>Private</strong> tab and select the <strong>GitHub</strong> option. Paste in the following GitHub URL which hosts the template for our project:</p>
<p>Next, select <strong>Submit</strong>:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/GitHubTemplate.png" /></p>
<p>Select your organization from the drop-down menu and type in a name for the new project that we are creating. In the example I will be naming the project <strong>TemplateAsCode</strong>. <strong>Check</strong> the box for <strong>The extension(s) are offered to you?</strong> and select <strong>Create Project</strong>:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/CreateProject.png" /></p>
<p>Notice that the <strong>Replace Tokens</strong> and <strong>Terraform</strong> <em>extensions</em> are required for this project. Extensions are add-ons for Azure DevOps that provide an enhancement to the service. In this case we will be using the Replace Tokens extension to build our Terraform configuration files during the build pipeline. Additionally, we are using the Terraform extension as well to easily deploy our configurations to Azure. These two extensions will automatically be installed when we import the project via the Azure DevOps Demo Generator.</p>
<p>Finally, after the import is successful, we will get the following message. Select <strong>Navigate to Project</strong> to be directed straight to our new project:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/ImportSuccessful.png" /></p>
<p>In the next step we will review the innerworkings of the project that we just imported.</p>
<h2>Step 2 ? Reviewing the Template as Code Design</h2>
<p>Let?s look at how the code repositories for this project are set up. On the left-hand side select <strong>Repos</strong> then choose <strong>Files</strong>. By selecting the drop down, we can see that there are two source code repositories or <em>repos</em> in our project. Select the <strong>ACI</strong> repo:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/SelectRepo.png" /></p>
<p>The <strong>ACI</strong> repo for this project contains the infrastructure code for the Azure Container Instances in our Azure environment with folders for Development and Production. In this project, instead of creating a repository for each application, or one for Dev and Prod, we are creating a repository for each cloud service or component. This allows for our infrastructure deployments to be simplified and as ?cookie cutter? as possible which really shines with large environments. The environment size and business needs will really play a role on the most effective repo structure design. But, for this demonstration we are going to go this route to keep things simple.</p>
<p>The pipelineconfig.yml is our build pipeline yaml file. If we look at the contents of this file, we can see it starts with the resources section. This is sourcing the code from our 2nd repo, <strong>templates</strong>, and allows us to use that repo code in our build pipeline. Next, is the stages section which contains our job and tasks for building the Terraform configurations. In the template section we are calling the template that we want to build which is pointing to the aci-prod-sampleapp2.yml file. When we deploy this pipeline, it will deploy the components in that template file which we will look at next:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/ACI.png" /></p>
<p>The other three yaml files in the <strong>ACI</strong> repo represent the Azure Container Instance infrastructure in our Production and Development environments. If we look at aci-prod-sampleapp2.yml , we can see that it?s a series of pipeline templates sourcing from the <strong>templates</strong> repo. The template parameters are what is making up the configuration of our components, in this example we have two templates, one for the resource group and one for the actual ACI component. Breaking up the resource group and the ACI resource into separate templates allows us to deploy more than one ACI resource to a resource group:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/liveinfrastructure.png" /></p>
<p>In our <strong>templates</strong> repo we can see our two yaml files for our pipeline templates along with a Terraform folder. This folder is where we keep our ?templatized? terraform configuration files. These files contain generic Terraform configuration files with variables that are surrounded by a double ?_?. This tells our Replace Tokens task, which runs during the build pipeline, to replace any strings in our container.tf and main.tf files that are surrounded by ?__? with it?s respective environment variable. So __CPU__ will be replaced by the CPU environment variable that we declare in the pipeline template:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/terraformtemplate.png" /></p>
<p>When looking at the azure-aci-rg.yml template, we can see at the top we are listing our parameters and then setting those as environment variables in the [email protected] task. Next is the [email protected] task. We are copying the Terraform configuration template file, main.tf , from the \Terraform\ACI directory of our source control repo to our $(Build.ArtifactStagingDirectory) . This is where we are building our Terraform files to produce as an <em>artifact</em>. An artifact, from a developer perspective, typically contains the compiled binaries and libraries used to run an application. These application files are then deployed to an environment in the release pipeline. With our IaC build pipeline, our Terraform configuration files are the artifacts in this case; and we will be deploying them with the release pipeline. In the last task we run the [email protected] task to swap out the variables surrounded by __ with our associated environment variable. This entire template allows us to take in parameter values and generate a Terraform configuration file from it:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/templates.png" /></p>
<p>If we look at the azure-aci-container.yml template, we can see the same structure as azure-aci-rg.yml . Since Azure Container Instances require many more values to create than a resource group, we have many more parameters declared at the beginning and in the [email protected] task, where we declare our environment variables. The key difference in this template is the extra [email protected] task at the end that renames the container.tf file to the name of the ACI resource. This allows us to create additional ACI resources in the same Terraform configuration by providing a unique name to the configuration file, so we don?t copy over any files:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/templates2.png" /></p>
<p>Now that we?ve reviewed our two repos, let?s wrap our head around the workflow in this build pipeline. Our pipelineconfig.yml file is our build pipeline file, which references the desired infrastructure yml file to build such as aci-prod-sampleapp1.yml . This file then points to several pipeline templates located in the <strong>templates</strong> repository which each build out the Terraform configuration files according to the parameter values specified in aci-prod-sampleapp1.yml . Finally, once our Terraform configuration files are built, they are published as an artifact which will then be used by our release pipeline to deploy to Azure:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/buildflowchart.png" /></p>
<p>In the next step we are going to deploy the Azure Container Instance infrastructure described in the aci-prod-sampleapp2.yml file.</p>
<h2>Step 3 ? Deploying Resources</h2>
<p>First, let?s run our build pipeline. On the left-hand side select <strong>Pipelines</strong> to expand the options underneath it. Then, once again, select <strong>Pipelines</strong> to see our build pipelines. Select <strong>Terraform-ACI-CI</strong> and select <strong>Run pipeline</strong>:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/runbuildpipeline.png" /></p>
<p>Select <strong>Run</strong> in the pop-up window to start our build pipeline. It will run for a minute or so and the artifacts will then be generated for our sampleapp2 infrastructure. We can view these artifacts by selecting <strong>1 published</strong> under the <strong>artifacts</strong> section:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/artifacts.png" /></p>
<p>We can see our Terraform configuration files for both ACI resources are there:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/terraformartifacts.png" /></p>
<p>Let?s deploy the infrastructure to our Azure subscription by running the release pipeline, but first we need to edit the release pipeline to configure a connection to our Azure subscription. On the left hand side expand <strong>Pipelines</strong> and select <strong>Releases</strong>. We can see our <strong>Terraform-ACI-CD</strong> pipeline has been imported, select <strong>Edit</strong>:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/editreleasepipeline.png" /></p>
<p>Under our <strong>Build</strong> stage select <strong>1 job, 5 tasks</strong> to edit our tasks to include our Azure subscription:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/editreleasetask.png" /></p>
<p>Select the first task <strong>Set up Azure Storage Account?</strong> and click on the drop-down box under <strong>Azure subscription</strong>. A list of subscriptions associated with your tenant will appear in this box. Select one that you would like to deploy the example Azure Container Instances too and select <strong>Authorize</strong>. You may be prompted to login to your Azure account. This process will create a Service Principal account in your Azure tenant and assign permissions to that subscription with that account. Azure DevOps will set this up as a service connection and use that to connect to Azure:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/addazuresubscription1.png" /></p>
<p>Next, we need to configure the remaining Terraform tasks with the same Azure service connection. The new connection that we made should now show up in the drop-down menu under <strong>Available Azure service connections</strong>. Select this for all 3 of the Terraform tasks that say <strong>some settings need attention</strong> this is because they are missing their Azure subscription settings:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/addazuresubscription2.png" /></p>
<p>Once complete, select <strong>Save</strong> at the top. Now we are ready to deploy our infrastructure. Select <strong>Create Release</strong> and then select <strong>Create</strong> to initiate the release pipeline. We will see a new message in green indicating that the release has been created. Select <strong>Release-1</strong> to view the release process for deploying the ACI resources into our Azure subscription:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/releasecreated.png" /></p>
<p>We will see that the release is running and can view the different steps of our release pipeline. This is a typical pipeline for deploying Terraform code, we provision a storage account to store our Terraform state, run a terraform init to initialize our Terraform environment and connect to our remote state (azure storage account in this case). Then we run a terraform plan to verify our configuration files have no issues. Finally if all the previous tasks are successful we run our terraform apply -auto-approve to deploy the infrastructure:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/releaserunning.png" /></p>
<p>Once our release has run successfully, we will see a <strong>Succeeded</strong> message:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/releasesucceeded.png" /></p>
<p>If we look in our Azure portal, we can see the resources are in fact there:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/azureresources.png" /></p>
<p>Next, we will add another ACI resource to our sampleapp2 application and redeploy our configuration with a pull request.</p>
<h2>Step 4 ? Modifying Resources with Pull Request</h2>
<p>We need to set up a branch policy for our <strong>master</strong> branch, this will allow us to automatically kick off a build if a Pull Request is initiated. To do this expand <strong>Repos</strong> and select <strong>Branches</strong>. On the <strong>master</strong> branch select the <strong>?</strong> all the way on the right side and select <strong>Branch policies</strong>:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/selectbranches.png" /></p>
<p>Select <strong>+ Add build policy</strong>. In the pop-up window, select our build pipeline <strong>Terraform-ACI-CI</strong> and keep the defaults for everything else. Select <strong>Save</strong> to create the build policy:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/branchpolicy.png" /></p>
<p>Now we are ready to submit a Pull Request and trigger a new build. Let?s create a new branch to make our changes in. In the <strong>ACI</strong> repository select the dropdown labeled <strong>master</strong> and select <strong>+ New Branch</strong>:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/newbranch.png" /></p>
<p>In our example we will name the new branch <strong>deploysampleapp2</strong>. Select <strong>Create</strong>. We are now actively using the new branch we just created in Azure DevOps. Select the aci-prod-sampleapp2.yml file and select <strong>Edit</strong> to edit the file. We are going to add another ACI resource by adding in another ACI template with the required parameters:</p>
<p>Next, select <strong>Commit</strong> to save our changes:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/editpipelineconfig.png" /></p>
<p>Select <strong>Commit</strong> again. Now there will be a pop up for a pull request, select <strong>Create a pull request</strong>:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/pullrequest.png" /></p>
<p>In the next window we can write in some information on our pull request and description. This provides great documentation for our deployments:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/pullrequestdescription.png" /></p>
<p>Select <strong>Create</strong>, and in the next windows select <strong>Set auto-complete</strong>. This will complete the Pull Request if our build runs successfully:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/pullrequestrunning.png" /></p>
<p>Then select <strong>set auto-complete</strong> again to confirm. Our build pipeline is now running with the changes from our new branch. If the build is successful, our branch will merge with the master branch with our new changes. Also note, if we look back at our pull request history, we can see a very simple outline of the new infrastructure that was added. This is one of the benefits of using the template parameters to define our infrastructure. Our pull requests get much easier to review:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/simplepullrequest.png" /></p>
<p>Now let?s go ahead and deploy our new resources. Expand <strong>Pipelines</strong> on the left-hand side and select <strong>Releases</strong>. Then select the <strong>Terraform-ACI-CD</strong> pipelines and select <strong>Create Release</strong>. Select <strong>Create</strong> to start deploying.</p>
<p>In our second release our additional ACI resource will be deployed. Once the release has been completed, we can double check in the Azure portal:</p>
<p style="clear: both"><img src="https://csprodstorage001.blob.core.windows.net/blog/azureresources2.png" /></p>
<h3>Conclusion</h3>
<p>In this article we imported a project that utilizes pipeline templates to generate Terraform configurations during the build pipeline. We also successfully deployed Azure Container Instance resources from these pipeline templates and even added additional resources using a Pull Request.</p>
<p>As you can see, this model can greatly simplify Infrastructure as Code environments and provide greater management and consistency. However, keep in mind that this strategy might not fit all scenarios. For example, a tiny environment might not need to go this far with only a few resources. They may be fine with just a few repositories with Terraform configurations stored inside them. Also, an extremely complex environment could be too limited by the templatized configurations and may require a much more complex set up.</p>
<p>The Infrastructure as Code model can become difficult to manage at large scale, using pipeline templates instead of treating our Terraform config files like sheep prevents us from creating snowflake infrastructure and allows us to scale our infrastructure rapidly and in a stable way.</p>
<p>For more information on Azure DevOps templates be sure to check out Microsoft?s documentation. Also, if you?re interested in learning more about Terraform take a look at their website for more material.</p>
<p><strong>Luke Orellana</strong> is a VMware vExpert who's been immersed in the IT Infrastructure realm since 2005. He's been creating technical blog content and guest speaking at Webinars throughout the years. His technology passions are Cloud and DevOps tools. As a life long learner Luke?s objective is to discover ways to automate tedious and troublesome tasks and to share his findings with others.</p>
<h2>Terraform azure devops</h2>

<h3>Terraform azure devops</h3>
<p>[youtube]</p>
Terraform azure devops <a href="http://remmont.com">News sites</a> Terraform azure devops
<h4>Terraform azure devops</h4>
Infrastructure as Code is considered a best practice when managing infrastructure in the cloud.
<h5>Terraform azure devops</h5>
Terraform azure devops <a href="http://remmont.com">Terraform azure devops</a> Terraform azure devops
SOURCE: <h6>Terraform azure devops</h6> <a href="https://dev-ops.engineer/">Terraform azure devops</a> Terraform azure devops
#tags#[replace: -,-Terraform azure devops] Terraform azure devops#tags#
https://ssylki.info/?who=apartment-list.remmont.com https://ssylki.info/?who=auto-detailing.remmont.com https://ssylki.info/?who=pre-owned-cars.remmont.com https://ssylki.info/?who=healthcare-insurance.remmont.com https://ssylki.info/?who=re....careers
Форум » Assassin's Creed: Общее » Книги и комиксы » Общая тема по литературе AC (Обсуждение)
  • Страница 3 из 3
  • «
  • 1
  • 2
  • 3
Поиск: