From da54342097a98e8ec8785fc0e2114eeade0524fb Mon Sep 17 00:00:00 2001 From: Laure-di Date: Thu, 10 Oct 2024 17:57:47 +0200 Subject: [PATCH 01/30] feat(apple-silicon): add tutorial ansible and terraform --- .../index.mdx | 170 ++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx new file mode 100644 index 0000000000..ed9214e928 --- /dev/null +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -0,0 +1,170 @@ +--- +meta: + title: Automating Apple Silicon Server Creation with Terraform and Ansible + description: Learn how to automate the creation and management of Apple Silicon servers using Terraform and Ansible. This guide provides step-by-step instructions for both tools +content: + h1: Automating Apple Silicon Server Creation with Terraform and Ansible + description: Learn how to automate the creation and management of Apple Silicon servers using Terraform and Ansible. This guide provides step-by-step instructions for both tools +categories: + - apple-silicon + - terraform + - ansible +tags: apple-silicon terraform ansible +--- + +In this tutorial, you'll explore two powerful tools, HashiCorp Terraform and Ansible, to set up and manage your Apple Silicon server. By automating infrastructure deployment and configuration, you can save time and reduce manual errors. + + + +- A Scaleway account logged into the [console](https://console.scaleway.com) +- [Owner](/identity-and-access-management/iam/concepts/#owner) status or [IAM permissions](/identity-and-access-management/iam/concepts/#permission) allowing you to perform actions in the intended Organization +- A valid [API key](/identity-and-access-management/iam/how-to/create-api-keys/) + +## Understanding the Tools + +### HashiCorp Terraform +[Terraform](https://www.terraform.io/) is an open-source tool that allows you to define and provision your infrastructure as code (IaC). It enables you to create reproducible environments and manage your infrastructure through versioned configuration files. + +### Ansible +[Ansible](https://www.ansible.com/) is an automation tool that uses playbooks to manage configurations and deploy applications. It helps maintain a clean and efficient directory structure, making automation tasks more manageable. + +## How to create an apple-silicon server + +### Using Terraform + +1. Download and install [Terraform](https://developer.hashicorp.com/terraform/install) + +2. Create a Directory: First, create a directory for your Terraform project. Open your terminal and run: + +```shell +mkdir apple_silicon_server_terraform +cd apple_silicon_server_terraform +``` + +3. Create a Terraform Configuration File: Inside this directory, create a file named resources.tf: + +```shell +touch resources.tf +``` + +4. Define the Required Providers: Open resources.tf in your preferred text editor and add the following code to specify the Scaleway provider and the required Terraform version: + +```shell +terraform { + required_providers { + scaleway = { + source = "scaleway/scaleway" + } + } + required_version = ">=0.13" +} + +``` + +5. Define the Apple Silicon Server: In the same resources.tf file, add the configuration to create your Apple Silicon server: + +```terraform +#resources.tf +resource "scaleway_apple_silicon_server" "server" { + name = "test-m2" + type = "M2-M" + zone = "fr-par-1" +} +``` + +6. Apply the Configuration: To apply this configuration, run the following commands in your terminal: + +```shell +#Initialize Terraform +terraform init +#Plan the deployment +terraform plan +#Create the server +terraform apply +``` + +When prompted, type yes to confirm the creation of the resources. + +### Using Ansible + +1. Install Ansible: You can install Ansible using pip, the Python package manager. Run the following command: + +```shell +pip install ansible +``` + +2. Install Scaleway Ansible Collection: Run the following command to install the Scaleway collection for Ansible: + +```shell +ansible-galaxy collection install scaleway.scaleway +``` + +3. Create a Directory: First, create a directory for your Ansible project. Open your terminal and run: + +```shell +mkdir apple_silicon_server_ansible +cd apple_silicon_server_ansible +``` + +4. Create a Playbook: Create a new file named create_applesilicon_server.yml: + +```shell +touch create_applesilicon_server.yml +``` + +5. Define the Playbook Content: Open create_applesilicon_server.yml in your text editor and add the following content: + +```ansible +--- +- name: Create Apple Silicon Server on Scaleway + hosts: localhost + gather_facts: no + tasks: + - name: Create an Apple Silicon server + scaleway.scaleway.scaleway_applesilicon_server: + access_key: "{{ scw_access_key }}" + secret_key: "{{ scw_secret_key }}" + state: present + type_: "M2-M" # Replace with your desired server type + name: "my-applesilicon-server" # Optional: specify a name for your server + zone: "fr-par-1" # Optional: specify the zone if needed + project_id: "your_project_id" # Optional: specify the project ID + register: applesilicon_server + + - name: Output server information + debug: + var: applesilicon_server +``` + +6. Ensure to replace your_project_id with your actual project ID if applicable. + +7. Replace Placeholders: Ensure to replace your_project_id with your actual project ID if applicable. + +```shell +ansible-playbook create_applesilicon_server.yml -e "scw_access_key=YOUR_ACCESS_KEY scw_secret_key=YOUR_SECRET_KEY" +``` +Replace YOUR_ACCESS_KEY and YOUR_SECRET_KEY with your actual Scaleway credentials. + +8. Check the Output: The playbook will output the details of the created server, including its ID, IP address, status, and other relevant information. + +## How to read server info + +### Using Terraform + +To read server information after creation, you can use the terraform output command, assuming you have defined output variables in your resources.tf. For example: + +```terraform +#resources.tf +output "server_ip" { + value = scaleway_apple_silicon_server.server.ip +} +``` + +After applying the configuration, run: + +```shell +terraform output server_ip +``` + +### Using Ansible + From 6e55a8eeb019a6b20fe914e7bcf23c7e182ed3b6 Mon Sep 17 00:00:00 2001 From: Laure-di Date: Thu, 20 Feb 2025 16:08:29 +0100 Subject: [PATCH 02/30] add some informations --- .../index.mdx | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index ed9214e928..06a48f3bf7 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -12,7 +12,7 @@ categories: tags: apple-silicon terraform ansible --- -In this tutorial, you'll explore two powerful tools, HashiCorp Terraform and Ansible, to set up and manage your Apple Silicon server. By automating infrastructure deployment and configuration, you can save time and reduce manual errors. +In this tutorial, we’ll guide you through automating the setup and management of Apple Silicon servers using two powerful tools: [Terraform](https://www.terraform.io/) and [Ansible](https://www.ansible.com/). By leveraging these tools, you can streamline infrastructure management, reduce manual configuration, and ensure consistent environments. @@ -23,10 +23,10 @@ In this tutorial, you'll explore two powerful tools, HashiCorp Terraform and Ans ## Understanding the Tools ### HashiCorp Terraform -[Terraform](https://www.terraform.io/) is an open-source tool that allows you to define and provision your infrastructure as code (IaC). It enables you to create reproducible environments and manage your infrastructure through versioned configuration files. +[Terraform](https://www.terraform.io/) is an open-source Infrastructure as Code (IaC) tool that allows you to define and manage infrastructure using declarative configuration files. Terraform enables you to create reproducible and scalable environments while automating the deployment of resources. ### Ansible -[Ansible](https://www.ansible.com/) is an automation tool that uses playbooks to manage configurations and deploy applications. It helps maintain a clean and efficient directory structure, making automation tasks more manageable. +[Ansible](https://www.ansible.com/) is an automation tool that simplifies configuration management, application deployment, and task automation. By using playbooks, Ansible helps automate and streamline processes, ensuring consistency and efficiency in managing complex infrastructure. ## How to create an apple-silicon server @@ -47,7 +47,7 @@ cd apple_silicon_server_terraform touch resources.tf ``` -4. Define the Required Providers: Open resources.tf in your preferred text editor and add the following code to specify the Scaleway provider and the required Terraform version: +4. Define the Required Providers: Open the resources.tf file and add the following configuration to define the Scaleway provider and set the required Terraform version: ```shell terraform { @@ -61,12 +61,12 @@ terraform { ``` -5. Define the Apple Silicon Server: In the same resources.tf file, add the configuration to create your Apple Silicon server: +5. Define the Apple Silicon Server: Add the following code to define your Apple Silicon server (M2-M type) in the same resources.tf file: ```terraform #resources.tf resource "scaleway_apple_silicon_server" "server" { - name = "test-m2" + name = "MyAwesomeServer" type = "M2-M" zone = "fr-par-1" } @@ -85,6 +85,37 @@ terraform apply When prompted, type yes to confirm the creation of the resources. +7. Enable Virtual Private Cloud (VPC) and Private Network: To enhance the network setup, you can update the configuration to enable VPC option and attach a private network to your Apple Silicon server. Update your resources.tf file with the following + +```terraform +#resources.tf +resource "scaleway_vpc" "vpc01" { + name = "MyAwesomeVPC" +} + +resource "scaleway_vpc_private_network" "pn01" { + name = "MyAwesomePN" + vpc_id = scaleway_vpc.vpc01.id +} + +resource "scaleway_apple_silicon_server" "server" { + name = "MyAwesomeServer" + type = "M2-M" + zone = "fr-par-1" + enable_vpc = true + private_network { + id = scaleway_vpc_private_network.pn01.id + } +} +``` +8. Apply the Configuration Update: Finally, run the following command to apply the changes and update the server configuration + +```shell +terraform apply +``` + +This will apply the new settings, ensuring that the server is launched within the specified VPC and connected to the private network. + ### Using Ansible 1. Install Ansible: You can install Ansible using pip, the Python package manager. Run the following command: From 942b17c283a1198c4b1d973cd1bb49c9db50d553 Mon Sep 17 00:00:00 2001 From: Laure-di Date: Tue, 25 Feb 2025 18:04:37 +0100 Subject: [PATCH 03/30] fix ansible and add conclusion --- .../index.mdx | 68 +++++++++++++------ 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index 06a48f3bf7..0e8ebf32e3 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -118,32 +118,34 @@ This will apply the new settings, ensuring that the server is launched within th ### Using Ansible -1. Install Ansible: You can install Ansible using pip, the Python package manager. Run the following command: +1. Install Ansible: If you don't have Ansible installed on your system, you can easily install it using pip, the Python package manager. Run the following command: ```shell pip install ansible ``` -2. Install Scaleway Ansible Collection: Run the following command to install the Scaleway collection for Ansible: +2. Install Scaleway Ansible Collection: Scaleway provides an official Ansible collection that enables you to interact with Scaleway resources, such as creating servers. Install this collection using the ansible-galaxy command: ```shell ansible-galaxy collection install scaleway.scaleway ``` -3. Create a Directory: First, create a directory for your Ansible project. Open your terminal and run: +3. Create a Directory: Now that you have Ansible and the Scaleway collection installed, create a directory for your Ansible project. This will help you keep everything organized. + +Run the following commands to create and navigate into the project directory: ```shell mkdir apple_silicon_server_ansible cd apple_silicon_server_ansible ``` -4. Create a Playbook: Create a new file named create_applesilicon_server.yml: +4. Create a Playbook: In Ansible, a playbook is a YAML file that defines the tasks to automate. Create a new file for your playbook, named create_applesilicon_server.yml: ```shell touch create_applesilicon_server.yml ``` -5. Define the Playbook Content: Open create_applesilicon_server.yml in your text editor and add the following content: +5. Define the Playbook Content: Open the create_applesilicon_server.yml file in your preferred text editor. Add the following content to define the task of provisioning an Apple Silicon server: ```ansible --- @@ -156,31 +158,31 @@ touch create_applesilicon_server.yml access_key: "{{ scw_access_key }}" secret_key: "{{ scw_secret_key }}" state: present - type_: "M2-M" # Replace with your desired server type - name: "my-applesilicon-server" # Optional: specify a name for your server - zone: "fr-par-1" # Optional: specify the zone if needed - project_id: "your_project_id" # Optional: specify the project ID + type_: "M2-M" + name: "my-applesilicon-server" + zone: "fr-par-1" + project_id: "{{scw_project_id}}" + vpc_enabled: "false" register: applesilicon_server - - - name: Output server information - debug: - var: applesilicon_server ``` -6. Ensure to replace your_project_id with your actual project ID if applicable. +6. Set Up Your Scaleway Credentials: Replace the placeholders {{ scw_access_key }}, {{ scw_secret_key }}, and {{ scw_project_id }} with your actual credentials. It’s a good practice to store these values in environment variables or an Ansible vault for added security. Alternatively, you can use a .env file or an external credentials file. + +7. Run the Playbook: Now that your playbook is ready and your credentials are set, you can run the playbook to create your Apple Silicon server. -7. Replace Placeholders: Ensure to replace your_project_id with your actual project ID if applicable. +Execute the following command: ```shell -ansible-playbook create_applesilicon_server.yml -e "scw_access_key=YOUR_ACCESS_KEY scw_secret_key=YOUR_SECRET_KEY" +ansible-playbook create_applesilicon_server.yml ``` -Replace YOUR_ACCESS_KEY and YOUR_SECRET_KEY with your actual Scaleway credentials. + +Ansible will authenticate using your credentials, and the playbook will automatically provision the Apple Silicon server based on the defined parameters. 8. Check the Output: The playbook will output the details of the created server, including its ID, IP address, status, and other relevant information. -## How to read server info +With these steps, you’ve successfully automated the creation of an Apple Silicon server on Scaleway using Ansible. You can now extend the playbook to configure your server or automate additional tasks as needed. -### Using Terraform +## How to read server info using Terraform To read server information after creation, you can use the terraform output command, assuming you have defined output variables in your resources.tf. For example: @@ -197,5 +199,31 @@ After applying the configuration, run: terraform output server_ip ``` -### Using Ansible +## Conclusion + +In this tutorial, we've explored how to automate the creation and management of Apple Silicon servers on Scaleway using two powerful tools: Terraform and Ansible. While both tools offer significant automation benefits, they each operate in distinct ways, which makes them suitable for different use cases. + +### Keys Differences + +#### Terraform's State Management + +Terraform maintains a state file that tracks the current status of your infrastructure. This state file acts as the source of truth for the resources created and managed by Terraform, providing you with visibility and control over any changes. This allows Terraform to efficiently handle infrastructure updates and deletions while ensuring consistency across environments. + +#### Ansible’s Idempotency + +Ansible, on the other hand, does not have a built-in state management system. Instead, it focuses on idempotency, meaning that Ansible playbooks can be executed multiple times without causing unwanted side effects. Each run checks whether the desired state is already achieved, and if not, it makes the necessary changes. However, Ansible doesn't retain a record of resource states, so it might be less efficient for large-scale infrastructure management compared to Terraform. + +### Which to choose? + +Terraform is an excellent choice for infrastructure provisioning where you need to keep track of your resources and manage dependencies between them. It is especially useful for handling lifecycle management (creation, modification, and deletion) of your infrastructure. + +Ansible shines in configuration management, automation, and orchestrating tasks across your infrastructure. It’s ideal for deploying applications, configuring services, and ensuring your systems are in the desired state after provisioning. + +You can also combine both tools for optimal results! Use Terraform for provisioning the infrastructure and Ansible for configuring the servers and deploying applications on top of it. This hybrid approach allows you to leverage the best of both worlds. + +By following this guide, you now have a solid understanding of how to automate the creation and management of Apple Silicon servers on Scaleway, whether you're using Terraform or Ansible. Both tools can greatly streamline your workflow, reduce manual effort, and help you maintain consistency across your infrastructure. + +For more advanced topics, consider exploring Terraform’s state management and Ansible’s playbook design to enhance your automation skills further. Happy automating! + + From c5c89f5a72ff163dc2f016f9702651a05ff64b24 Mon Sep 17 00:00:00 2001 From: Laure-di Date: Wed, 26 Feb 2025 10:27:01 +0100 Subject: [PATCH 04/30] improve title --- .../index.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index 0e8ebf32e3..12c60df83b 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -1,10 +1,10 @@ --- meta: - title: Automating Apple Silicon Server Creation with Terraform and Ansible - description: Learn how to automate the creation and management of Apple Silicon servers using Terraform and Ansible. This guide provides step-by-step instructions for both tools + title: Automating Apple Silicon Server Creation: A Step-by-Step Guide Using Terraform vs. Ansible + description: Explore Two Powerful Approaches to Automating Apple Silicon Server Deployment with Terraform and Ansible content: - h1: Automating Apple Silicon Server Creation with Terraform and Ansible - description: Learn how to automate the creation and management of Apple Silicon servers using Terraform and Ansible. This guide provides step-by-step instructions for both tools + h1: Automating Apple Silicon Server Creation: A Step-by-Step Guide Using Terraform vs. Ansible + description: Explore Two Powerful Approaches to Automating Apple Silicon Server Deployment with Terraform and Ansible categories: - apple-silicon - terraform From daeda84278cfc2322c397cbf33205eedf8178771 Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:06:59 +0100 Subject: [PATCH 05/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index 12c60df83b..9b764973ed 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -170,13 +170,13 @@ touch create_applesilicon_server.yml 7. Run the Playbook: Now that your playbook is ready and your credentials are set, you can run the playbook to create your Apple Silicon server. -Execute the following command: - -```shell -ansible-playbook create_applesilicon_server.yml -``` - -Ansible will authenticate using your credentials, and the playbook will automatically provision the Apple Silicon server based on the defined parameters. + Execute the following command: + + ```shell + ansible-playbook create_applesilicon_server.yml + ``` + + Ansible will authenticate using your credentials, and the playbook will automatically provision the Apple Silicon server based on the defined parameters. 8. Check the Output: The playbook will output the details of the created server, including its ID, IP address, status, and other relevant information. From 10f14b823070ac1c0d859569d1a8cf426ffee0ab Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:07:13 +0100 Subject: [PATCH 06/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index 9b764973ed..2f98a06660 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -221,7 +221,7 @@ Ansible shines in configuration management, automation, and orchestrating tasks You can also combine both tools for optimal results! Use Terraform for provisioning the infrastructure and Ansible for configuring the servers and deploying applications on top of it. This hybrid approach allows you to leverage the best of both worlds. -By following this guide, you now have a solid understanding of how to automate the creation and management of Apple Silicon servers on Scaleway, whether you're using Terraform or Ansible. Both tools can greatly streamline your workflow, reduce manual effort, and help you maintain consistency across your infrastructure. +By following this guide, you now have a solid understanding of how to automate the creation and management of Apple silicon servers on Scaleway, whether you're using Terraform or Ansible. Both tools can greatly streamline your workflow, reduce manual effort, and help you maintain consistency across your infrastructure. For more advanced topics, consider exploring Terraform’s state management and Ansible’s playbook design to enhance your automation skills further. Happy automating! From f95f5ac62cf9e6d8c4c0d66ddd7a7107669bfe68 Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:07:23 +0100 Subject: [PATCH 07/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index 2f98a06660..620f609c84 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -211,7 +211,7 @@ Terraform maintains a state file that tracks the current status of your infrastr #### Ansible’s Idempotency -Ansible, on the other hand, does not have a built-in state management system. Instead, it focuses on idempotency, meaning that Ansible playbooks can be executed multiple times without causing unwanted side effects. Each run checks whether the desired state is already achieved, and if not, it makes the necessary changes. However, Ansible doesn't retain a record of resource states, so it might be less efficient for large-scale infrastructure management compared to Terraform. +Ansible, on the other hand, does not have a built-in state management system. Instead, it focuses on idempotency, meaning that Ansible playbooks can be executed multiple times without causing unwanted side effects. Each run checks whether the desired state is already achieved, and if not, it makes the necessary changes. However, Ansible does not retain a record of resource states, so it might be less efficient for large-scale infrastructure management compared to Terraform. ### Which to choose? From e7e06c59a5e8ba5bb4f18d26c48979e7848ebcc1 Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:08:32 +0100 Subject: [PATCH 08/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index 620f609c84..b7254915c4 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -12,7 +12,7 @@ categories: tags: apple-silicon terraform ansible --- -In this tutorial, we’ll guide you through automating the setup and management of Apple Silicon servers using two powerful tools: [Terraform](https://www.terraform.io/) and [Ansible](https://www.ansible.com/). By leveraging these tools, you can streamline infrastructure management, reduce manual configuration, and ensure consistent environments. +In this tutorial, we will guide you through automating the setup and management of Apple Silicon servers using two powerful tools: [Terraform](https://www.terraform.io/) and [Ansible](https://www.ansible.com/). By leveraging these tools, you can streamline infrastructure management, reduce manual configuration, and ensure consistent environments. From 3de747400403bc8f4297c0f223fe31a6074c205f Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:08:50 +0100 Subject: [PATCH 09/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index b7254915c4..2525ee5788 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -20,7 +20,7 @@ In this tutorial, we will guide you through automating the setup and management - [Owner](/identity-and-access-management/iam/concepts/#owner) status or [IAM permissions](/identity-and-access-management/iam/concepts/#permission) allowing you to perform actions in the intended Organization - A valid [API key](/identity-and-access-management/iam/how-to/create-api-keys/) -## Understanding the Tools +## Understanding the tools ### HashiCorp Terraform [Terraform](https://www.terraform.io/) is an open-source Infrastructure as Code (IaC) tool that allows you to define and manage infrastructure using declarative configuration files. Terraform enables you to create reproducible and scalable environments while automating the deployment of resources. From e1e1e706881003747db0aff454f61494f5434f5a Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:08:59 +0100 Subject: [PATCH 10/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index 2525ee5788..9e923a8f29 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -203,7 +203,7 @@ terraform output server_ip In this tutorial, we've explored how to automate the creation and management of Apple Silicon servers on Scaleway using two powerful tools: Terraform and Ansible. While both tools offer significant automation benefits, they each operate in distinct ways, which makes them suitable for different use cases. -### Keys Differences +### Keys differences #### Terraform's State Management From bf469218118e71ddf0b43696b54a42fc31a6ffa7 Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:09:08 +0100 Subject: [PATCH 11/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index 9e923a8f29..e0325d1fcb 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -209,7 +209,7 @@ In this tutorial, we've explored how to automate the creation and management of Terraform maintains a state file that tracks the current status of your infrastructure. This state file acts as the source of truth for the resources created and managed by Terraform, providing you with visibility and control over any changes. This allows Terraform to efficiently handle infrastructure updates and deletions while ensuring consistency across environments. -#### Ansible’s Idempotency +#### Ansible’s idempotency Ansible, on the other hand, does not have a built-in state management system. Instead, it focuses on idempotency, meaning that Ansible playbooks can be executed multiple times without causing unwanted side effects. Each run checks whether the desired state is already achieved, and if not, it makes the necessary changes. However, Ansible does not retain a record of resource states, so it might be less efficient for large-scale infrastructure management compared to Terraform. From 69e20b7572a6319022829769b95848a1a91a642e Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:09:37 +0100 Subject: [PATCH 12/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index e0325d1fcb..551daa4119 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -28,7 +28,7 @@ In this tutorial, we will guide you through automating the setup and management ### Ansible [Ansible](https://www.ansible.com/) is an automation tool that simplifies configuration management, application deployment, and task automation. By using playbooks, Ansible helps automate and streamline processes, ensuring consistency and efficiency in managing complex infrastructure. -## How to create an apple-silicon server +## How to create an Apple silicon server ### Using Terraform From 15d131be7107af6104e1feb320ea222a8a436692 Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:10:08 +0100 Subject: [PATCH 13/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index 551daa4119..9e98f6f463 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -32,7 +32,7 @@ In this tutorial, we will guide you through automating the setup and management ### Using Terraform -1. Download and install [Terraform](https://developer.hashicorp.com/terraform/install) +1. Download and install [Terraform](https://developer.hashicorp.com/terraform/install). 2. Create a Directory: First, create a directory for your Terraform project. Open your terminal and run: From f39170263f33ff4d5daa0cf4110cb32844e57c9b Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:10:17 +0100 Subject: [PATCH 14/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index 9e98f6f463..fe636f8d52 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -205,7 +205,7 @@ In this tutorial, we've explored how to automate the creation and management of ### Keys differences -#### Terraform's State Management +#### Terraform's state management Terraform maintains a state file that tracks the current status of your infrastructure. This state file acts as the source of truth for the resources created and managed by Terraform, providing you with visibility and control over any changes. This allows Terraform to efficiently handle infrastructure updates and deletions while ensuring consistency across environments. From e2cf6a3975ea5225bc74b2a1ff8445372f8e5c95 Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:10:30 +0100 Subject: [PATCH 15/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index fe636f8d52..b61d46a986 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -41,7 +41,7 @@ mkdir apple_silicon_server_terraform cd apple_silicon_server_terraform ``` -3. Create a Terraform Configuration File: Inside this directory, create a file named resources.tf: +3. Create a Terraform configuration file: Inside this directory, create a file named `resources.tf`: ```shell touch resources.tf From 77dd5c81dd34d7e076a9b7902942c7ab52fbe08e Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:10:46 +0100 Subject: [PATCH 16/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index b61d46a986..b933e8c4f5 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -47,7 +47,7 @@ cd apple_silicon_server_terraform touch resources.tf ``` -4. Define the Required Providers: Open the resources.tf file and add the following configuration to define the Scaleway provider and set the required Terraform version: +4. Define the required providers: Open the `resources.tf` file and add the following configuration to define the Scaleway provider and set the required Terraform version: ```shell terraform { From 99201b08d7d9dced7bcdb7d2ec17967aa3288d30 Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:11:01 +0100 Subject: [PATCH 17/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index b933e8c4f5..ee6da9ab9a 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -43,9 +43,9 @@ cd apple_silicon_server_terraform 3. Create a Terraform configuration file: Inside this directory, create a file named `resources.tf`: -```shell -touch resources.tf -``` + ```shell + touch resources.tf + ``` 4. Define the required providers: Open the `resources.tf` file and add the following configuration to define the Scaleway provider and set the required Terraform version: From ab8bfd59c13c1b8cc7e593cb070f940985c0fd33 Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:11:16 +0100 Subject: [PATCH 18/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index ee6da9ab9a..6f19bb6ceb 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -61,7 +61,7 @@ terraform { ``` -5. Define the Apple Silicon Server: Add the following code to define your Apple Silicon server (M2-M type) in the same resources.tf file: +5. Define the Apple silicon server: Add the following code to define your Apple silicon server (M2-M type) in the same `resources.tf` file: ```terraform #resources.tf From 5014db361d713daf1187bcc4e0b4bccea5c40229 Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:11:36 +0100 Subject: [PATCH 19/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index 6f19bb6ceb..fbfc456dd4 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -72,7 +72,7 @@ resource "scaleway_apple_silicon_server" "server" { } ``` -6. Apply the Configuration: To apply this configuration, run the following commands in your terminal: +6. Apply the configuration: To apply this configuration, run the following commands in your terminal: ```shell #Initialize Terraform From 18e463b8c764bab5201239894b48534b363699e3 Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:12:01 +0100 Subject: [PATCH 20/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index fbfc456dd4..116bbc6afa 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -83,7 +83,7 @@ terraform plan terraform apply ``` -When prompted, type yes to confirm the creation of the resources. +When prompted, type **yes** to confirm the creation of the resources. 7. Enable Virtual Private Cloud (VPC) and Private Network: To enhance the network setup, you can update the configuration to enable VPC option and attach a private network to your Apple Silicon server. Update your resources.tf file with the following From 09f33385b56caba95d32c71f213ce1072c528c11 Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:12:14 +0100 Subject: [PATCH 21/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index 116bbc6afa..750bec9a68 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -85,7 +85,7 @@ terraform apply When prompted, type **yes** to confirm the creation of the resources. -7. Enable Virtual Private Cloud (VPC) and Private Network: To enhance the network setup, you can update the configuration to enable VPC option and attach a private network to your Apple Silicon server. Update your resources.tf file with the following +7. Enable Virtual Private Cloud (VPC) and a Private Network: To enhance the network setup, you can update the configuration to enable VPC option and attach a Private Network to your Apple silicon server. Update your `resources.tf` file with the following: ```terraform #resources.tf From c8fb09b066d6e887041b2623f97f79e3a682b7a3 Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:12:30 +0100 Subject: [PATCH 22/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index 750bec9a68..79950bc418 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -108,7 +108,7 @@ resource "scaleway_apple_silicon_server" "server" { } } ``` -8. Apply the Configuration Update: Finally, run the following command to apply the changes and update the server configuration +8. Apply the configuration update: Run the following command to apply the changes and update the server configuration ```shell terraform apply From 3680e53ae641f1f4fa31e9aac484c4030b3f7eb4 Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:12:51 +0100 Subject: [PATCH 23/30] Update tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx Co-authored-by: Benedikt Rollik --- .../index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index 79950bc418..bea84a2716 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -114,7 +114,7 @@ resource "scaleway_apple_silicon_server" "server" { terraform apply ``` -This will apply the new settings, ensuring that the server is launched within the specified VPC and connected to the private network. +This will apply the new settings, ensuring that the server is launched within the specified VPC and connected to the Private Network. ### Using Ansible From f529dd20bf579bc01bb832a3a133a82ae9317553 Mon Sep 17 00:00:00 2001 From: Laure-di <62625835+Laure-di@users.noreply.github.com> Date: Thu, 27 Feb 2025 11:14:17 +0100 Subject: [PATCH 24/30] Apply suggestions from code review Co-authored-by: Benedikt Rollik --- .../index.mdx | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx index bea84a2716..3974f9b905 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx @@ -124,36 +124,36 @@ This will apply the new settings, ensuring that the server is launched within th pip install ansible ``` -2. Install Scaleway Ansible Collection: Scaleway provides an official Ansible collection that enables you to interact with Scaleway resources, such as creating servers. Install this collection using the ansible-galaxy command: +2. Install Scaleway Ansible Collection: Scaleway provides an official Ansible collection that enables you to interact with Scaleway resources, such as creating servers. Install this collection using the `ansible-galaxy` command: ```shell ansible-galaxy collection install scaleway.scaleway ``` -3. Create a Directory: Now that you have Ansible and the Scaleway collection installed, create a directory for your Ansible project. This will help you keep everything organized. +3. Create a directory: Now that you have Ansible and the Scaleway collection installed, create a directory for your Ansible project. This will help you keep everything organized. -Run the following commands to create and navigate into the project directory: - -```shell -mkdir apple_silicon_server_ansible -cd apple_silicon_server_ansible -``` + Run the following commands to create and navigate into the project directory: + + ```shell + mkdir apple_silicon_server_ansible + cd apple_silicon_server_ansible + ``` -4. Create a Playbook: In Ansible, a playbook is a YAML file that defines the tasks to automate. Create a new file for your playbook, named create_applesilicon_server.yml: +4. Create a playbook: In Ansible, a playbook is a YAML file that defines the tasks to automate. Create a new file for your playbook named `create_applesilicon_server.yml`: ```shell touch create_applesilicon_server.yml ``` -5. Define the Playbook Content: Open the create_applesilicon_server.yml file in your preferred text editor. Add the following content to define the task of provisioning an Apple Silicon server: +5. Define the playbook content: Open the `create_applesilicon_server.yml` file in your preferred text editor. Add the following content to define the task of provisioning an Apple silicon server: ```ansible --- -- name: Create Apple Silicon Server on Scaleway +- name: Create Apple silicon server on Scaleway hosts: localhost gather_facts: no tasks: - - name: Create an Apple Silicon server + - name: Create an Apple silicon server scaleway.scaleway.scaleway_applesilicon_server: access_key: "{{ scw_access_key }}" secret_key: "{{ scw_secret_key }}" @@ -166,9 +166,9 @@ touch create_applesilicon_server.yml register: applesilicon_server ``` -6. Set Up Your Scaleway Credentials: Replace the placeholders {{ scw_access_key }}, {{ scw_secret_key }}, and {{ scw_project_id }} with your actual credentials. It’s a good practice to store these values in environment variables or an Ansible vault for added security. Alternatively, you can use a .env file or an external credentials file. +6. Set up your Scaleway credentials: Replace the placeholders {{ scw_access_key }}, {{ scw_secret_key }}, and {{ scw_project_id }} with your actual credentials. It is a good practice to store these values in environment variables or an Ansible vault for added security. Alternatively, you can use a `.env` file or an external credentials file. -7. Run the Playbook: Now that your playbook is ready and your credentials are set, you can run the playbook to create your Apple Silicon server. +7. Run the playbook: Now that your playbook is ready and your credentials are set, you can run the playbook to create your Apple silicon server. Execute the following command: @@ -178,13 +178,13 @@ touch create_applesilicon_server.yml Ansible will authenticate using your credentials, and the playbook will automatically provision the Apple Silicon server based on the defined parameters. -8. Check the Output: The playbook will output the details of the created server, including its ID, IP address, status, and other relevant information. +8. Check the output: The playbook will output the details of the created server, including its ID, IP address, status, and other relevant information. -With these steps, you’ve successfully automated the creation of an Apple Silicon server on Scaleway using Ansible. You can now extend the playbook to configure your server or automate additional tasks as needed. +With these steps, you have successfully automated the creation of an Apple silicon server on Scaleway using Ansible. You can now extend the playbook to configure your server or automate additional tasks as needed. ## How to read server info using Terraform -To read server information after creation, you can use the terraform output command, assuming you have defined output variables in your resources.tf. For example: +To read server information after creation, you can use the terraform output command, assuming you have defined output variables in your `resources.tf`. For example: ```terraform #resources.tf @@ -201,7 +201,7 @@ terraform output server_ip ## Conclusion -In this tutorial, we've explored how to automate the creation and management of Apple Silicon servers on Scaleway using two powerful tools: Terraform and Ansible. While both tools offer significant automation benefits, they each operate in distinct ways, which makes them suitable for different use cases. +In this tutorial, we have explored how to automate the creation and management of Apple silicon servers on Scaleway using two powerful tools: Terraform and Ansible. While both tools offer significant automation benefits, they each operate in distinct ways, which makes them suitable for different use cases. ### Keys differences From 29957681ef100959a35e83108b7f262a056030d8 Mon Sep 17 00:00:00 2001 From: Laure-di Date: Tue, 11 Mar 2025 09:17:03 +0100 Subject: [PATCH 25/30] split tutorial --- .../index.mdx | 0 .../index.mdx | 118 ++++++------------ 2 files changed, 40 insertions(+), 78 deletions(-) create mode 100644 tutorials/how-to-setup-applesilicon-server-with-ansible/index.mdx rename tutorials/{how-to-setup-applesilicon-server-with-terraform-ansible => how-to-setup-applesilicon-server-with-terraform}/index.mdx (62%) diff --git a/tutorials/how-to-setup-applesilicon-server-with-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-ansible/index.mdx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx similarity index 62% rename from tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx rename to tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx index 3974f9b905..2dc3e6f187 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx @@ -1,18 +1,17 @@ --- meta: - title: Automating Apple Silicon Server Creation: A Step-by-Step Guide Using Terraform vs. Ansible - description: Explore Two Powerful Approaches to Automating Apple Silicon Server Deployment with Terraform and Ansible + title: Automating Apple Silicon Server Creation: A Step-by-Step Guide Using Terraform + description: Explore Two Powerful Approaches to Automating Apple Silicon Server Deployment with Terraform content: - h1: Automating Apple Silicon Server Creation: A Step-by-Step Guide Using Terraform vs. Ansible - description: Explore Two Powerful Approaches to Automating Apple Silicon Server Deployment with Terraform and Ansible + h1: Automating Apple Silicon Server Creation: A Step-by-Step Guide Using Terraform + description: Explore Two Powerful Approaches to Automating Apple Silicon Server Deployment with Terraform categories: - apple-silicon - terraform - - ansible -tags: apple-silicon terraform ansible +tags: apple-silicon ansible --- -In this tutorial, we will guide you through automating the setup and management of Apple Silicon servers using two powerful tools: [Terraform](https://www.terraform.io/) and [Ansible](https://www.ansible.com/). By leveraging these tools, you can streamline infrastructure management, reduce manual configuration, and ensure consistent environments. +In this tutorial, we will guide you through automating the setup and management of Apple Silicon servers using a powerful tool: [Terraform](https://www.terraform.io/). By leveraging these tools, you can streamline infrastructure management, reduce manual configuration, and ensure consistent environments. @@ -20,17 +19,17 @@ In this tutorial, we will guide you through automating the setup and management - [Owner](/identity-and-access-management/iam/concepts/#owner) status or [IAM permissions](/identity-and-access-management/iam/concepts/#permission) allowing you to perform actions in the intended Organization - A valid [API key](/identity-and-access-management/iam/how-to/create-api-keys/) -## Understanding the tools +## Understanding the tool + +### HashiCorp Terraform & OpenTofu -### HashiCorp Terraform [Terraform](https://www.terraform.io/) is an open-source Infrastructure as Code (IaC) tool that allows you to define and manage infrastructure using declarative configuration files. Terraform enables you to create reproducible and scalable environments while automating the deployment of resources. -### Ansible -[Ansible](https://www.ansible.com/) is an automation tool that simplifies configuration management, application deployment, and task automation. By using playbooks, Ansible helps automate and streamline processes, ensuring consistency and efficiency in managing complex infrastructure. +A fork of this project, [OpenTofu](https://opentofu.org/), is an open-source alternative that aims to be fully compatible with Terraform, while offering an independent, community-driven approach. OpenTofu provides the same functionality as Terraform, allowing users to define infrastructure with HCL (HashiCorp Configuration Language) and automate resource management. Its goal is to offer a transparent and open solution, with an emphasis on inclusivity and community contributions. -## How to create an Apple silicon server +Both Terraform and OpenTofu offer the same core functionality for provisioning and managing infrastructure. If you are familiar with Terraform, you can easily switch to OpenTofu without needing to change your configuration files. -### Using Terraform +## How to create an Apple silicon server 1. Download and install [Terraform](https://developer.hashicorp.com/terraform/install). @@ -116,88 +115,51 @@ terraform apply This will apply the new settings, ensuring that the server is launched within the specified VPC and connected to the Private Network. -### Using Ansible - -1. Install Ansible: If you don't have Ansible installed on your system, you can easily install it using pip, the Python package manager. Run the following command: - -```shell -pip install ansible -``` +## How to read server info using Terraform -2. Install Scaleway Ansible Collection: Scaleway provides an official Ansible collection that enables you to interact with Scaleway resources, such as creating servers. Install this collection using the `ansible-galaxy` command: +To read server information after creation, you can use the terraform output command, assuming you have defined output variables in your `resources.tf`. For example: -```shell -ansible-galaxy collection install scaleway.scaleway +```terraform +#resources.tf +output "server_ip" { + value = scaleway_apple_silicon_server.server.ip +} ``` -3. Create a directory: Now that you have Ansible and the Scaleway collection installed, create a directory for your Ansible project. This will help you keep everything organized. - - Run the following commands to create and navigate into the project directory: - - ```shell - mkdir apple_silicon_server_ansible - cd apple_silicon_server_ansible - ``` - -4. Create a playbook: In Ansible, a playbook is a YAML file that defines the tasks to automate. Create a new file for your playbook named `create_applesilicon_server.yml`: +After applying the configuration, run: ```shell -touch create_applesilicon_server.yml -``` - -5. Define the playbook content: Open the `create_applesilicon_server.yml` file in your preferred text editor. Add the following content to define the task of provisioning an Apple silicon server: - -```ansible ---- -- name: Create Apple silicon server on Scaleway - hosts: localhost - gather_facts: no - tasks: - - name: Create an Apple silicon server - scaleway.scaleway.scaleway_applesilicon_server: - access_key: "{{ scw_access_key }}" - secret_key: "{{ scw_secret_key }}" - state: present - type_: "M2-M" - name: "my-applesilicon-server" - zone: "fr-par-1" - project_id: "{{scw_project_id}}" - vpc_enabled: "false" - register: applesilicon_server +terraform output server_ip ``` -6. Set up your Scaleway credentials: Replace the placeholders {{ scw_access_key }}, {{ scw_secret_key }}, and {{ scw_project_id }} with your actual credentials. It is a good practice to store these values in environment variables or an Ansible vault for added security. Alternatively, you can use a `.env` file or an external credentials file. - -7. Run the playbook: Now that your playbook is ready and your credentials are set, you can run the playbook to create your Apple silicon server. +## Delve into Terraform with local-exec, remote-exec and null_resource - Execute the following command: - - ```shell - ansible-playbook create_applesilicon_server.yml - ``` - - Ansible will authenticate using your credentials, and the playbook will automatically provision the Apple Silicon server based on the defined parameters. +In Terraform, provisioners like local-exec, remote-exec, and null_resource can be used to automate the execution of scripts and manage resource configuration. Here’s how you can use them: -8. Check the output: The playbook will output the details of the created server, including its ID, IP address, status, and other relevant information. +[null_resource](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) is a special Terraform resource that doesn’t manage infrastructure directly. It serves as a placeholder for running provisioners and triggers actions without creating any infrastructure. +[remote-exec](https://developer.hashicorp.com/terraform/language/resources/provisioners/remote-exec) provisioner allows you to execute scripts on remote resources after they’ve been created. It is useful for configuring remote servers or performing post-creation actions. +[local-exec](https://developer.hashicorp.com/terraform/language/resources/provisioners/local-exec) provisioner enables you to run scripts on your local machine. This is helpful when you need to execute commands in your local environment based on the resources created by Terraform. -With these steps, you have successfully automated the creation of an Apple silicon server on Scaleway using Ansible. You can now extend the playbook to configure your server or automate additional tasks as needed. +1. We want to connect to our server, so we are going to retrieve all the connection information -## How to read server info using Terraform - -To read server information after creation, you can use the terraform output command, assuming you have defined output variables in your `resources.tf`. For example: +``` terraform +#resource.tf -```terraform -#resources.tf -output "server_ip" { - value = scaleway_apple_silicon_server.server.ip +resource "null_resource" "store_ssh_key" { + provisioner "local-exec" { + command = <<-EOT + mkdir -p ~/.ssh + echo "${file("~/.ssh/id_rsa")}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + echo 'SSH key stored at ~/.ssh/id_rsa' + EOT + } } ``` -After applying the configuration, run: +2. To install dependancies which can be usefull + -```shell -terraform output server_ip -``` ## Conclusion From 0f533c75255e2ddfd2adb3f0e55be8ef780b434e Mon Sep 17 00:00:00 2001 From: Laure-di Date: Wed, 12 Mar 2025 14:21:15 +0100 Subject: [PATCH 26/30] feat(apple-silicon): ansible tutorial --- .../index.mdx | 229 ++++++++++++++++++ 1 file changed, 229 insertions(+) diff --git a/tutorials/how-to-setup-applesilicon-server-with-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-ansible/index.mdx index e69de29bb2..dd30aa3ff3 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-ansible/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-ansible/index.mdx @@ -0,0 +1,229 @@ +--- +meta: +title: Automating Apple Silicon Server Creation: A Step-by-Step Guide Using Terraform vs. Ansible +description: Explore Two Powerful Approaches to Automating Apple Silicon Server Deployment with Terraform and Ansible +content: +h1: Automating Apple Silicon Server Creation: A Step-by-Step Guide Using Terraform vs. Ansible +description: Explore Two Powerful Approaches to Automating Apple Silicon Server Deployment with Terraform and Ansible +categories: +- apple-silicon +- terraform +- ansible +tags: apple-silicon terraform ansible +--- + +In this tutorial, we will guide you through automating the setup and management of Apple Silicon servers using two powerful tools: [Terraform](https://www.terraform.io/) and [Ansible](https://www.ansible.com/). By leveraging these tools, you can streamline infrastructure management, reduce manual configuration, and ensure consistent environments. + + + +- A Scaleway account logged into the [console](https://console.scaleway.com) +- [Owner](/identity-and-access-management/iam/concepts/#owner) status or [IAM permissions](/identity-and-access-management/iam/concepts/#permission) allowing you to perform actions in the intended Organization +- A valid [API key](/identity-and-access-management/iam/how-to/create-api-keys/) + +## Understanding the tools + +### HashiCorp Terraform +[Terraform](https://www.terraform.io/) is an open-source Infrastructure as Code (IaC) tool that allows you to define and manage infrastructure using declarative configuration files. Terraform enables you to create reproducible and scalable environments while automating the deployment of resources. + +### Ansible +[Ansible](https://www.ansible.com/) is an automation tool that simplifies configuration management, application deployment, and task automation. By using playbooks, Ansible helps automate and streamline processes, ensuring consistency and efficiency in managing complex infrastructure. + +## How to create an Apple silicon server + +### Using Terraform + +1. Download and install [Terraform](https://developer.hashicorp.com/terraform/install). + +2. Create a Directory: First, create a directory for your Terraform project. Open your terminal and run: + +```shell +mkdir apple_silicon_server_terraform +cd apple_silicon_server_terraform +``` + +3. Create a Terraform configuration file: Inside this directory, create a file named `resources.tf`: + + ```shell + touch resources.tf + ``` + +4. Define the required providers: Open the `resources.tf` file and add the following configuration to define the Scaleway provider and set the required Terraform version: + +```shell +terraform { + required_providers { + scaleway = { + source = "scaleway/scaleway" + } + } + required_version = ">=0.13" +} + +``` + +5. Define the Apple silicon server: Add the following code to define your Apple silicon server (M2-M type) in the same `resources.tf` file: + +```terraform +#resources.tf +resource "scaleway_apple_silicon_server" "server" { + name = "MyAwesomeServer" + type = "M2-M" + zone = "fr-par-1" +} +``` + +6. Apply the configuration: To apply this configuration, run the following commands in your terminal: + +```shell +#Initialize Terraform +terraform init +#Plan the deployment +terraform plan +#Create the server +terraform apply +``` + +When prompted, type **yes** to confirm the creation of the resources. + +7. Enable Virtual Private Cloud (VPC) and a Private Network: To enhance the network setup, you can update the configuration to enable VPC option and attach a Private Network to your Apple silicon server. Update your `resources.tf` file with the following: + +```terraform +#resources.tf +resource "scaleway_vpc" "vpc01" { + name = "MyAwesomeVPC" +} + +resource "scaleway_vpc_private_network" "pn01" { + name = "MyAwesomePN" + vpc_id = scaleway_vpc.vpc01.id +} + +resource "scaleway_apple_silicon_server" "server" { + name = "MyAwesomeServer" + type = "M2-M" + zone = "fr-par-1" + enable_vpc = true + private_network { + id = scaleway_vpc_private_network.pn01.id + } +} +``` +8. Apply the configuration update: Run the following command to apply the changes and update the server configuration + +```shell +terraform apply +``` + +This will apply the new settings, ensuring that the server is launched within the specified VPC and connected to the Private Network. + +### Using Ansible + +1. Install Ansible: If you don't have Ansible installed on your system, you can easily install it using pip, the Python package manager. Run the following command: + +```shell +pip install ansible +``` + +2. Install Scaleway Ansible Collection: Scaleway provides an official Ansible collection that enables you to interact with Scaleway resources, such as creating servers. Install this collection using the `ansible-galaxy` command: + +```shell +ansible-galaxy collection install scaleway.scaleway +``` + +3. Create a directory: Now that you have Ansible and the Scaleway collection installed, create a directory for your Ansible project. This will help you keep everything organized. + +Run the following commands to create and navigate into the project directory: + + ```shell + mkdir apple_silicon_server_ansible + cd apple_silicon_server_ansible + ``` + +4. Create a playbook: In Ansible, a playbook is a YAML file that defines the tasks to automate. Create a new file for your playbook named `create_applesilicon_server.yml`: + +```shell +touch create_applesilicon_server.yml +``` + +5. Define the playbook content: Open the `create_applesilicon_server.yml` file in your preferred text editor. Add the following content to define the task of provisioning an Apple silicon server: + +```ansible +--- +- name: Create Apple silicon server on Scaleway + hosts: localhost + gather_facts: no + tasks: + - name: Create an Apple silicon server + scaleway.scaleway.scaleway_applesilicon_server: + access_key: "{{ scw_access_key }}" + secret_key: "{{ scw_secret_key }}" + state: present + type_: "M2-M" + name: "my-applesilicon-server" + zone: "fr-par-1" + project_id: "{{scw_project_id}}" + vpc_enabled: "false" + register: applesilicon_server +``` + +6. Set up your Scaleway credentials: Replace the placeholders {{ scw_access_key }}, {{ scw_secret_key }}, and {{ scw_project_id }} with your actual credentials. It is a good practice to store these values in environment variables or an Ansible vault for added security. Alternatively, you can use a `.env` file or an external credentials file. + +7. Run the playbook: Now that your playbook is ready and your credentials are set, you can run the playbook to create your Apple silicon server. + +Execute the following command: + + ```shell + ansible-playbook create_applesilicon_server.yml + ``` + +Ansible will authenticate using your credentials, and the playbook will automatically provision the Apple Silicon server based on the defined parameters. + +8. Check the output: The playbook will output the details of the created server, including its ID, IP address, status, and other relevant information. + +With these steps, you have successfully automated the creation of an Apple silicon server on Scaleway using Ansible. You can now extend the playbook to configure your server or automate additional tasks as needed. + +## How to read server info using Terraform + +To read server information after creation, you can use the terraform output command, assuming you have defined output variables in your `resources.tf`. For example: + +```terraform +#resources.tf +output "server_ip" { + value = scaleway_apple_silicon_server.server.ip +} +``` + +After applying the configuration, run: + +```shell +terraform output server_ip +``` + +## Conclusion + +In this tutorial, we have explored how to automate the creation and management of Apple silicon servers on Scaleway using two powerful tools: Terraform and Ansible. While both tools offer significant automation benefits, they each operate in distinct ways, which makes them suitable for different use cases. + +### Keys differences + +#### Terraform's state management + +Terraform maintains a state file that tracks the current status of your infrastructure. This state file acts as the source of truth for the resources created and managed by Terraform, providing you with visibility and control over any changes. This allows Terraform to efficiently handle infrastructure updates and deletions while ensuring consistency across environments. + +#### Ansible’s idempotency + +Ansible, on the other hand, does not have a built-in state management system. Instead, it focuses on idempotency, meaning that Ansible playbooks can be executed multiple times without causing unwanted side effects. Each run checks whether the desired state is already achieved, and if not, it makes the necessary changes. However, Ansible does not retain a record of resource states, so it might be less efficient for large-scale infrastructure management compared to Terraform. + +### Which to choose? + +Terraform is an excellent choice for infrastructure provisioning where you need to keep track of your resources and manage dependencies between them. It is especially useful for handling lifecycle management (creation, modification, and deletion) of your infrastructure. + +Ansible shines in configuration management, automation, and orchestrating tasks across your infrastructure. It’s ideal for deploying applications, configuring services, and ensuring your systems are in the desired state after provisioning. + +You can also combine both tools for optimal results! Use Terraform for provisioning the infrastructure and Ansible for configuring the servers and deploying applications on top of it. This hybrid approach allows you to leverage the best of both worlds. + +By following this guide, you now have a solid understanding of how to automate the creation and management of Apple silicon servers on Scaleway, whether you're using Terraform or Ansible. Both tools can greatly streamline your workflow, reduce manual effort, and help you maintain consistency across your infrastructure. + +For more advanced topics, consider exploring Terraform’s state management and Ansible’s playbook design to enhance your automation skills further. Happy automating! + + + From 4658002ef1a5ade5ff578551c8583fb0b45a26e4 Mon Sep 17 00:00:00 2001 From: Laure-di Date: Tue, 18 Mar 2025 09:43:57 +0100 Subject: [PATCH 27/30] add management dependencies terraform --- .../index.mdx | 229 ------------------ .../index.mdx | 81 ++++--- 2 files changed, 47 insertions(+), 263 deletions(-) delete mode 100644 tutorials/how-to-setup-applesilicon-server-with-ansible/index.mdx diff --git a/tutorials/how-to-setup-applesilicon-server-with-ansible/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-ansible/index.mdx deleted file mode 100644 index dd30aa3ff3..0000000000 --- a/tutorials/how-to-setup-applesilicon-server-with-ansible/index.mdx +++ /dev/null @@ -1,229 +0,0 @@ ---- -meta: -title: Automating Apple Silicon Server Creation: A Step-by-Step Guide Using Terraform vs. Ansible -description: Explore Two Powerful Approaches to Automating Apple Silicon Server Deployment with Terraform and Ansible -content: -h1: Automating Apple Silicon Server Creation: A Step-by-Step Guide Using Terraform vs. Ansible -description: Explore Two Powerful Approaches to Automating Apple Silicon Server Deployment with Terraform and Ansible -categories: -- apple-silicon -- terraform -- ansible -tags: apple-silicon terraform ansible ---- - -In this tutorial, we will guide you through automating the setup and management of Apple Silicon servers using two powerful tools: [Terraform](https://www.terraform.io/) and [Ansible](https://www.ansible.com/). By leveraging these tools, you can streamline infrastructure management, reduce manual configuration, and ensure consistent environments. - - - -- A Scaleway account logged into the [console](https://console.scaleway.com) -- [Owner](/identity-and-access-management/iam/concepts/#owner) status or [IAM permissions](/identity-and-access-management/iam/concepts/#permission) allowing you to perform actions in the intended Organization -- A valid [API key](/identity-and-access-management/iam/how-to/create-api-keys/) - -## Understanding the tools - -### HashiCorp Terraform -[Terraform](https://www.terraform.io/) is an open-source Infrastructure as Code (IaC) tool that allows you to define and manage infrastructure using declarative configuration files. Terraform enables you to create reproducible and scalable environments while automating the deployment of resources. - -### Ansible -[Ansible](https://www.ansible.com/) is an automation tool that simplifies configuration management, application deployment, and task automation. By using playbooks, Ansible helps automate and streamline processes, ensuring consistency and efficiency in managing complex infrastructure. - -## How to create an Apple silicon server - -### Using Terraform - -1. Download and install [Terraform](https://developer.hashicorp.com/terraform/install). - -2. Create a Directory: First, create a directory for your Terraform project. Open your terminal and run: - -```shell -mkdir apple_silicon_server_terraform -cd apple_silicon_server_terraform -``` - -3. Create a Terraform configuration file: Inside this directory, create a file named `resources.tf`: - - ```shell - touch resources.tf - ``` - -4. Define the required providers: Open the `resources.tf` file and add the following configuration to define the Scaleway provider and set the required Terraform version: - -```shell -terraform { - required_providers { - scaleway = { - source = "scaleway/scaleway" - } - } - required_version = ">=0.13" -} - -``` - -5. Define the Apple silicon server: Add the following code to define your Apple silicon server (M2-M type) in the same `resources.tf` file: - -```terraform -#resources.tf -resource "scaleway_apple_silicon_server" "server" { - name = "MyAwesomeServer" - type = "M2-M" - zone = "fr-par-1" -} -``` - -6. Apply the configuration: To apply this configuration, run the following commands in your terminal: - -```shell -#Initialize Terraform -terraform init -#Plan the deployment -terraform plan -#Create the server -terraform apply -``` - -When prompted, type **yes** to confirm the creation of the resources. - -7. Enable Virtual Private Cloud (VPC) and a Private Network: To enhance the network setup, you can update the configuration to enable VPC option and attach a Private Network to your Apple silicon server. Update your `resources.tf` file with the following: - -```terraform -#resources.tf -resource "scaleway_vpc" "vpc01" { - name = "MyAwesomeVPC" -} - -resource "scaleway_vpc_private_network" "pn01" { - name = "MyAwesomePN" - vpc_id = scaleway_vpc.vpc01.id -} - -resource "scaleway_apple_silicon_server" "server" { - name = "MyAwesomeServer" - type = "M2-M" - zone = "fr-par-1" - enable_vpc = true - private_network { - id = scaleway_vpc_private_network.pn01.id - } -} -``` -8. Apply the configuration update: Run the following command to apply the changes and update the server configuration - -```shell -terraform apply -``` - -This will apply the new settings, ensuring that the server is launched within the specified VPC and connected to the Private Network. - -### Using Ansible - -1. Install Ansible: If you don't have Ansible installed on your system, you can easily install it using pip, the Python package manager. Run the following command: - -```shell -pip install ansible -``` - -2. Install Scaleway Ansible Collection: Scaleway provides an official Ansible collection that enables you to interact with Scaleway resources, such as creating servers. Install this collection using the `ansible-galaxy` command: - -```shell -ansible-galaxy collection install scaleway.scaleway -``` - -3. Create a directory: Now that you have Ansible and the Scaleway collection installed, create a directory for your Ansible project. This will help you keep everything organized. - -Run the following commands to create and navigate into the project directory: - - ```shell - mkdir apple_silicon_server_ansible - cd apple_silicon_server_ansible - ``` - -4. Create a playbook: In Ansible, a playbook is a YAML file that defines the tasks to automate. Create a new file for your playbook named `create_applesilicon_server.yml`: - -```shell -touch create_applesilicon_server.yml -``` - -5. Define the playbook content: Open the `create_applesilicon_server.yml` file in your preferred text editor. Add the following content to define the task of provisioning an Apple silicon server: - -```ansible ---- -- name: Create Apple silicon server on Scaleway - hosts: localhost - gather_facts: no - tasks: - - name: Create an Apple silicon server - scaleway.scaleway.scaleway_applesilicon_server: - access_key: "{{ scw_access_key }}" - secret_key: "{{ scw_secret_key }}" - state: present - type_: "M2-M" - name: "my-applesilicon-server" - zone: "fr-par-1" - project_id: "{{scw_project_id}}" - vpc_enabled: "false" - register: applesilicon_server -``` - -6. Set up your Scaleway credentials: Replace the placeholders {{ scw_access_key }}, {{ scw_secret_key }}, and {{ scw_project_id }} with your actual credentials. It is a good practice to store these values in environment variables or an Ansible vault for added security. Alternatively, you can use a `.env` file or an external credentials file. - -7. Run the playbook: Now that your playbook is ready and your credentials are set, you can run the playbook to create your Apple silicon server. - -Execute the following command: - - ```shell - ansible-playbook create_applesilicon_server.yml - ``` - -Ansible will authenticate using your credentials, and the playbook will automatically provision the Apple Silicon server based on the defined parameters. - -8. Check the output: The playbook will output the details of the created server, including its ID, IP address, status, and other relevant information. - -With these steps, you have successfully automated the creation of an Apple silicon server on Scaleway using Ansible. You can now extend the playbook to configure your server or automate additional tasks as needed. - -## How to read server info using Terraform - -To read server information after creation, you can use the terraform output command, assuming you have defined output variables in your `resources.tf`. For example: - -```terraform -#resources.tf -output "server_ip" { - value = scaleway_apple_silicon_server.server.ip -} -``` - -After applying the configuration, run: - -```shell -terraform output server_ip -``` - -## Conclusion - -In this tutorial, we have explored how to automate the creation and management of Apple silicon servers on Scaleway using two powerful tools: Terraform and Ansible. While both tools offer significant automation benefits, they each operate in distinct ways, which makes them suitable for different use cases. - -### Keys differences - -#### Terraform's state management - -Terraform maintains a state file that tracks the current status of your infrastructure. This state file acts as the source of truth for the resources created and managed by Terraform, providing you with visibility and control over any changes. This allows Terraform to efficiently handle infrastructure updates and deletions while ensuring consistency across environments. - -#### Ansible’s idempotency - -Ansible, on the other hand, does not have a built-in state management system. Instead, it focuses on idempotency, meaning that Ansible playbooks can be executed multiple times without causing unwanted side effects. Each run checks whether the desired state is already achieved, and if not, it makes the necessary changes. However, Ansible does not retain a record of resource states, so it might be less efficient for large-scale infrastructure management compared to Terraform. - -### Which to choose? - -Terraform is an excellent choice for infrastructure provisioning where you need to keep track of your resources and manage dependencies between them. It is especially useful for handling lifecycle management (creation, modification, and deletion) of your infrastructure. - -Ansible shines in configuration management, automation, and orchestrating tasks across your infrastructure. It’s ideal for deploying applications, configuring services, and ensuring your systems are in the desired state after provisioning. - -You can also combine both tools for optimal results! Use Terraform for provisioning the infrastructure and Ansible for configuring the servers and deploying applications on top of it. This hybrid approach allows you to leverage the best of both worlds. - -By following this guide, you now have a solid understanding of how to automate the creation and management of Apple silicon servers on Scaleway, whether you're using Terraform or Ansible. Both tools can greatly streamline your workflow, reduce manual effort, and help you maintain consistency across your infrastructure. - -For more advanced topics, consider exploring Terraform’s state management and Ansible’s playbook design to enhance your automation skills further. Happy automating! - - - diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx index 2dc3e6f187..e2ca394036 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx @@ -115,9 +115,9 @@ terraform apply This will apply the new settings, ensuring that the server is launched within the specified VPC and connected to the Private Network. -## How to read server info using Terraform +## Retrieve Server Information -To read server information after creation, you can use the terraform output command, assuming you have defined output variables in your `resources.tf`. For example: +You can retrieve server information after the creation by using the terraform output command. To do so, you need to define output variables in your resources.tf. For example: ```terraform #resources.tf @@ -132,60 +132,73 @@ After applying the configuration, run: terraform output server_ip ``` -## Delve into Terraform with local-exec, remote-exec and null_resource +## Delving into Terraform Provisioners: local-exec, remote-exec, and null_resource -In Terraform, provisioners like local-exec, remote-exec, and null_resource can be used to automate the execution of scripts and manage resource configuration. Here’s how you can use them: +Provisioners in Terraform help automate the execution of tasks. You can use local-exec, remote-exec, and null_resource to trigger actions in your environment. Here’s an overview of how they work: -[null_resource](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) is a special Terraform resource that doesn’t manage infrastructure directly. It serves as a placeholder for running provisioners and triggers actions without creating any infrastructure. -[remote-exec](https://developer.hashicorp.com/terraform/language/resources/provisioners/remote-exec) provisioner allows you to execute scripts on remote resources after they’ve been created. It is useful for configuring remote servers or performing post-creation actions. -[local-exec](https://developer.hashicorp.com/terraform/language/resources/provisioners/local-exec) provisioner enables you to run scripts on your local machine. This is helpful when you need to execute commands in your local environment based on the resources created by Terraform. +[null_resource](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) This placeholder allows you to run provisioners without managing infrastructure directly. It triggers actions based on dependencies but doesn’t create or modify resources. +[remote-exec](https://developer.hashicorp.com/terraform/language/resources/provisioners/remote-exec) This provisioner executes scripts on remote servers, making it ideal for configuring your infrastructure or performing post-creation tasks. +[local-exec](https://developer.hashicorp.com/terraform/language/resources/provisioners/local-exec) This provisioner allows you to execute commands locally, on your local machine, after creating resources in Terraform. -1. We want to connect to our server, so we are going to retrieve all the connection information +### Storing the SSH Key Locally + +You can use the local-exec provisioner to store the SSH key of the server on your local machine, preventing future verification prompts: ``` terraform #resource.tf -resource "null_resource" "store_ssh_key" { +resource "null_resource" "store_server_ssh_key" { + depends_on = [scaleway_apple_silicon_server.server] + provisioner "local-exec" { command = <<-EOT - mkdir -p ~/.ssh - echo "${file("~/.ssh/id_rsa")}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - echo 'SSH key stored at ~/.ssh/id_rsa' + ssh-keyscan -H ${scaleway_apple_silicon_server.server.ip} >> ~/.ssh/known_hosts + echo "Stored SSH public key for ${scaleway_apple_silicon_server.server.ip}" EOT } } ``` +### Installing Homebrew and Dependencies -2. To install dependancies which can be usefull - - - -## Conclusion - -In this tutorial, we have explored how to automate the creation and management of Apple silicon servers on Scaleway using two powerful tools: Terraform and Ansible. While both tools offer significant automation benefits, they each operate in distinct ways, which makes them suitable for different use cases. - -### Keys differences +Next, we can use remote-exec to install Homebrew and other essential dependencies on the server: -#### Terraform's state management - -Terraform maintains a state file that tracks the current status of your infrastructure. This state file acts as the source of truth for the resources created and managed by Terraform, providing you with visibility and control over any changes. This allows Terraform to efficiently handle infrastructure updates and deletions while ensuring consistency across environments. - -#### Ansible’s idempotency +```terraform +resource "null_resource" "install_homebrew_and_dependencies" { + depends_on = [scaleway_apple_silicon_server.server] + + provisioner "remote-exec" { + inline = [ + "echo 'Installing Homebrew on the server...'", + "which brew || /bin/bash -c '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)'", + "echo 'Adding Homebrew to the PATH...'", + "echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.zshrc", + "source ~/.zshrc", + "echo 'Installing essential dependencies...'", + "brew install git wget curl", + "echo 'Homebrew and dependencies installed.'", + ] + + connection { + type = "ssh" + user = scaleway_apple_silicon_server.server.username + host = scaleway_apple_silicon_server.server.ip + password = scaleway_apple_silicon_server.server.password + timeout = "5m" + } + } +} -Ansible, on the other hand, does not have a built-in state management system. Instead, it focuses on idempotency, meaning that Ansible playbooks can be executed multiple times without causing unwanted side effects. Each run checks whether the desired state is already achieved, and if not, it makes the necessary changes. However, Ansible does not retain a record of resource states, so it might be less efficient for large-scale infrastructure management compared to Terraform. +``` -### Which to choose? -Terraform is an excellent choice for infrastructure provisioning where you need to keep track of your resources and manage dependencies between them. It is especially useful for handling lifecycle management (creation, modification, and deletion) of your infrastructure. -Ansible shines in configuration management, automation, and orchestrating tasks across your infrastructure. It’s ideal for deploying applications, configuring services, and ensuring your systems are in the desired state after provisioning. +## Conclusion -You can also combine both tools for optimal results! Use Terraform for provisioning the infrastructure and Ansible for configuring the servers and deploying applications on top of it. This hybrid approach allows you to leverage the best of both worlds. +In this tutorial, we have explored how to automate the creation and management of Apple Silicon servers on Scaleway using Terraform. By leveraging Terraform’s infrastructure as code (IaC) capabilities, we streamlined server creation, network configuration, and the installation of essential dependencies. However, it’s important to note that while Terraform excels at managing infrastructure and automating deployments, it has limitations when it comes to handling more complex dependencies and configurations that may evolve over time. -By following this guide, you now have a solid understanding of how to automate the creation and management of Apple silicon servers on Scaleway, whether you're using Terraform or Ansible. Both tools can greatly streamline your workflow, reduce manual effort, and help you maintain consistency across your infrastructure. +For more intricate use cases, especially when managing complex configurations or handling dependencies between various resources, Ansible is a better fit. Ansible offers a more flexible, agentless approach to configuration management, where it excels in defining and automating tasks like installing software, configuring system settings, and managing service dependencies. It is ideal for handling the post-provisioning setup or when orchestrating multiple servers across your infrastructure. -For more advanced topics, consider exploring Terraform’s state management and Ansible’s playbook design to enhance your automation skills further. Happy automating! +In an upcoming tutorial, we will dive deeper into how Ansible can be integrated into your workflow for managing dependencies and handling more advanced server configurations, enhancing the automation process beyond simple infrastructure provisioning. From 260c4b6363a62948f7a5ca06f770d8e3a550aef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Mon, 31 Mar 2025 10:28:12 +0200 Subject: [PATCH 28/30] Apply suggestions from code review Co-authored-by: Benedikt Rollik --- .../index.mdx | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx index e2ca394036..4c9b8d95e5 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx @@ -1,17 +1,17 @@ --- meta: - title: Automating Apple Silicon Server Creation: A Step-by-Step Guide Using Terraform - description: Explore Two Powerful Approaches to Automating Apple Silicon Server Deployment with Terraform + title: Automating Apple silicon server creation: A step-by-step guide using Terraform + description: Explore two powerful approaches to automating Apple silicon server deployment with Terraform content: - h1: Automating Apple Silicon Server Creation: A Step-by-Step Guide Using Terraform - description: Explore Two Powerful Approaches to Automating Apple Silicon Server Deployment with Terraform + h1: Automating Apple silicon server creation: A step-by-step guide using Terraform + description: Explore two powerful approaches to automating Apple silicon server deployment with Terraform categories: - apple-silicon - terraform tags: apple-silicon ansible --- -In this tutorial, we will guide you through automating the setup and management of Apple Silicon servers using a powerful tool: [Terraform](https://www.terraform.io/). By leveraging these tools, you can streamline infrastructure management, reduce manual configuration, and ensure consistent environments. +In this tutorial, we will guide you through automating the setup and management of Apple silicon servers using a powerful tool: [Terraform](https://www.terraform.io/). By leveraging these tools, you can streamline infrastructure management, reduce manual configuration, and ensure consistent environments. @@ -33,7 +33,7 @@ Both Terraform and OpenTofu offer the same core functionality for provisioning a 1. Download and install [Terraform](https://developer.hashicorp.com/terraform/install). -2. Create a Directory: First, create a directory for your Terraform project. Open your terminal and run: +2. Create a directory: First, create a directory for your Terraform project. Open your terminal and run: ```shell mkdir apple_silicon_server_terraform @@ -84,7 +84,7 @@ terraform apply When prompted, type **yes** to confirm the creation of the resources. -7. Enable Virtual Private Cloud (VPC) and a Private Network: To enhance the network setup, you can update the configuration to enable VPC option and attach a Private Network to your Apple silicon server. Update your `resources.tf` file with the following: +7. Enable Virtual Private Cloud (VPC) and a Private Network: To enhance the network setup, you can update the configuration to enable the VPC option and attach a Private Network to your Apple silicon server. Update your `resources.tf` file with the following: ```terraform #resources.tf @@ -107,7 +107,7 @@ resource "scaleway_apple_silicon_server" "server" { } } ``` -8. Apply the configuration update: Run the following command to apply the changes and update the server configuration +8. Apply the configuration update: Run the following command to apply the changes and update the server configuration: ```shell terraform apply @@ -115,9 +115,9 @@ terraform apply This will apply the new settings, ensuring that the server is launched within the specified VPC and connected to the Private Network. -## Retrieve Server Information +## Retrieve server information -You can retrieve server information after the creation by using the terraform output command. To do so, you need to define output variables in your resources.tf. For example: +You can retrieve your server information after the creation by using the terraform output command. To do so, you need to define output variables in your resources.tf. For example: ```terraform #resources.tf @@ -140,7 +140,7 @@ Provisioners in Terraform help automate the execution of tasks. You can use loca [remote-exec](https://developer.hashicorp.com/terraform/language/resources/provisioners/remote-exec) This provisioner executes scripts on remote servers, making it ideal for configuring your infrastructure or performing post-creation tasks. [local-exec](https://developer.hashicorp.com/terraform/language/resources/provisioners/local-exec) This provisioner allows you to execute commands locally, on your local machine, after creating resources in Terraform. -### Storing the SSH Key Locally +### Storing the SSH key Locally You can use the local-exec provisioner to store the SSH key of the server on your local machine, preventing future verification prompts: @@ -158,7 +158,7 @@ resource "null_resource" "store_server_ssh_key" { } } ``` -### Installing Homebrew and Dependencies +### Installing Homebrew and dependencies Next, we can use remote-exec to install Homebrew and other essential dependencies on the server: @@ -189,16 +189,11 @@ resource "null_resource" "install_homebrew_and_dependencies" { } ``` - - - ## Conclusion -In this tutorial, we have explored how to automate the creation and management of Apple Silicon servers on Scaleway using Terraform. By leveraging Terraform’s infrastructure as code (IaC) capabilities, we streamlined server creation, network configuration, and the installation of essential dependencies. However, it’s important to note that while Terraform excels at managing infrastructure and automating deployments, it has limitations when it comes to handling more complex dependencies and configurations that may evolve over time. +In this tutorial, we have explored how to automate the creation and management of Apple silicon servers on Scaleway using Terraform. By leveraging Terraform’s infrastructure as code (IaC) capabilities, we streamlined server creation, network configuration, and the installation of essential dependencies. However, it is important to note that while Terraform excels at managing infrastructure and automating deployments, it has limitations when it comes to handling more complex dependencies and configurations that may evolve over time. For more intricate use cases, especially when managing complex configurations or handling dependencies between various resources, Ansible is a better fit. Ansible offers a more flexible, agentless approach to configuration management, where it excels in defining and automating tasks like installing software, configuring system settings, and managing service dependencies. It is ideal for handling the post-provisioning setup or when orchestrating multiple servers across your infrastructure. In an upcoming tutorial, we will dive deeper into how Ansible can be integrated into your workflow for managing dependencies and handling more advanced server configurations, enhancing the automation process beyond simple infrastructure provisioning. - - From b844b84202fde30cb20a26b7a397091d01150b2d Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Wed, 21 May 2025 10:43:39 +0200 Subject: [PATCH 29/30] Apply suggestions from code review Co-authored-by: ldecarvalho-doc <82805470+ldecarvalho-doc@users.noreply.github.com> --- .../index.mdx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx index 4c9b8d95e5..d3e72fe236 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx @@ -33,20 +33,20 @@ Both Terraform and OpenTofu offer the same core functionality for provisioning a 1. Download and install [Terraform](https://developer.hashicorp.com/terraform/install). -2. Create a directory: First, create a directory for your Terraform project. Open your terminal and run: +2. Create a directory for your Terraform project. Open your terminal and run the following command: ```shell mkdir apple_silicon_server_terraform cd apple_silicon_server_terraform ``` -3. Create a Terraform configuration file: Inside this directory, create a file named `resources.tf`: +3. Create a Terraform configuration file. Inside the directory, create a file named `resources.tf`: ```shell touch resources.tf ``` -4. Define the required providers: Open the `resources.tf` file and add the following configuration to define the Scaleway provider and set the required Terraform version: +4. Define the required providers. Open the `resources.tf` file and add the following configuration to define the Scaleway provider and set the required Terraform version: ```shell terraform { @@ -60,7 +60,7 @@ terraform { ``` -5. Define the Apple silicon server: Add the following code to define your Apple silicon server (M2-M type) in the same `resources.tf` file: +5. Define the Apple silicon server. Add the following code to define your Apple silicon server (M2-M type) in the same `resources.tf` file: ```terraform #resources.tf @@ -71,7 +71,7 @@ resource "scaleway_apple_silicon_server" "server" { } ``` -6. Apply the configuration: To apply this configuration, run the following commands in your terminal: +6. Run the following commands in your terminal to apply the configuration: ```shell #Initialize Terraform @@ -84,7 +84,7 @@ terraform apply When prompted, type **yes** to confirm the creation of the resources. -7. Enable Virtual Private Cloud (VPC) and a Private Network: To enhance the network setup, you can update the configuration to enable the VPC option and attach a Private Network to your Apple silicon server. Update your `resources.tf` file with the following: +7. Enable Virtual Private Cloud (VPC) and a Private Network. To enhance the network setup, you can update the configuration to enable the VPC option and attach a Private Network to your Apple silicon server. Update your `resources.tf` file with the following: ```terraform #resources.tf @@ -107,7 +107,7 @@ resource "scaleway_apple_silicon_server" "server" { } } ``` -8. Apply the configuration update: Run the following command to apply the changes and update the server configuration: +8. Run the following command to apply the changes and update the server configuration: ```shell terraform apply From e08befe63a38fb5afd90acf4d64c315e08f0ad36 Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Wed, 21 May 2025 11:24:14 +0200 Subject: [PATCH 30/30] feat(apple-silicon): doc review and updates --- .../index.mdx | 137 ++++++++++-------- 1 file changed, 77 insertions(+), 60 deletions(-) diff --git a/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx b/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx index d3e72fe236..a03f407a00 100644 --- a/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx +++ b/tutorials/how-to-setup-applesilicon-server-with-terraform/index.mdx @@ -1,9 +1,9 @@ --- meta: - title: Automating Apple silicon server creation: A step-by-step guide using Terraform + title: Automating Apple silicon server creation using Terraform description: Explore two powerful approaches to automating Apple silicon server deployment with Terraform content: - h1: Automating Apple silicon server creation: A step-by-step guide using Terraform + h1: Automating Apple silicon server creation using Terraform description: Explore two powerful approaches to automating Apple silicon server deployment with Terraform categories: - apple-silicon @@ -35,10 +35,10 @@ Both Terraform and OpenTofu offer the same core functionality for provisioning a 2. Create a directory for your Terraform project. Open your terminal and run the following command: -```shell -mkdir apple_silicon_server_terraform -cd apple_silicon_server_terraform -``` + ```shell + mkdir apple_silicon_server_terraform + cd apple_silicon_server_terraform + ``` 3. Create a Terraform configuration file. Inside the directory, create a file named `resources.tf`: @@ -48,83 +48,86 @@ cd apple_silicon_server_terraform 4. Define the required providers. Open the `resources.tf` file and add the following configuration to define the Scaleway provider and set the required Terraform version: -```shell -terraform { - required_providers { - scaleway = { - source = "scaleway/scaleway" + ```shell + terraform { + required_providers { + scaleway = { + source = "scaleway/scaleway" + } + } + required_version = ">=0.13" } - } - required_version = ">=0.13" -} -``` + ``` 5. Define the Apple silicon server. Add the following code to define your Apple silicon server (M2-M type) in the same `resources.tf` file: -```terraform -#resources.tf -resource "scaleway_apple_silicon_server" "server" { - name = "MyAwesomeServer" - type = "M2-M" - zone = "fr-par-1" -} -``` + ```terraform + resource "scaleway_apple_silicon_server" "server" { + name = "MyAwesomeServer" + type = "M2-M" + zone = "fr-par-1" + } + ``` 6. Run the following commands in your terminal to apply the configuration: -```shell -#Initialize Terraform -terraform init -#Plan the deployment -terraform plan -#Create the server -terraform apply -``` + ```shell + #Initialize Terraform + terraform init + #Plan the deployment + terraform plan + #Create the server + terraform apply + ``` When prompted, type **yes** to confirm the creation of the resources. 7. Enable Virtual Private Cloud (VPC) and a Private Network. To enhance the network setup, you can update the configuration to enable the VPC option and attach a Private Network to your Apple silicon server. Update your `resources.tf` file with the following: -```terraform -#resources.tf -resource "scaleway_vpc" "vpc01" { - name = "MyAwesomeVPC" -} + ```terraform + #resources.tf + resource "scaleway_vpc" "vpc01" { + name = "MyAwesomeVPC" + } -resource "scaleway_vpc_private_network" "pn01" { - name = "MyAwesomePN" - vpc_id = scaleway_vpc.vpc01.id -} + resource "scaleway_vpc_private_network" "pn01" { + name = "MyAwesomePN" + vpc_id = scaleway_vpc.vpc01.id + } -resource "scaleway_apple_silicon_server" "server" { - name = "MyAwesomeServer" - type = "M2-M" - zone = "fr-par-1" - enable_vpc = true - private_network { - id = scaleway_vpc_private_network.pn01.id + resource "scaleway_apple_silicon_server" "server" { + name = "MyAwesomeServer" + type = "M2-M" + zone = "fr-par-1" + enable_vpc = true + private_network { + id = scaleway_vpc_private_network.pn01.id + } } -} -``` + ``` + 8. Run the following command to apply the changes and update the server configuration: -```shell -terraform apply -``` + ```shell + terraform apply + ``` + +This will apply the new settings, ensuring that the server is launched within the specified VPC and connected to the Private Network. -This will apply the new settings, ensuring that the server is launched within the specified VPC and connected to the Private Network. + +You can log in to the [Scaleway console](https://console.scaleway.com/asaas/servers) to view the Apple silicon server you just created. + ## Retrieve server information -You can retrieve your server information after the creation by using the terraform output command. To do so, you need to define output variables in your resources.tf. For example: +You can retrieve your server information after the creation by using the terraform output command. To do so, you need to define output variables in your `resources.tf`. For example: -```terraform -#resources.tf -output "server_ip" { - value = scaleway_apple_silicon_server.server.ip -} -``` + ```terraform + output "server_ip" { + value = scaleway_apple_silicon_server.server.ip + } + ``` After applying the configuration, run: @@ -158,6 +161,20 @@ resource "null_resource" "store_server_ssh_key" { } } ``` + + + If the error message below displays, run `terraform init -upgrade` to solve the issue. + ``` + Error: Inconsistent dependency lock file + + The following dependency selections recorded in the lock file are inconsistent with the current configuration: + - provider registry.terraform.io/hashicorp/null: required by this configuration but no version is selected + + To update the locked dependency selections to match a changed configuration, run: + terraform init -upgrade + ``` + + ### Installing Homebrew and dependencies Next, we can use remote-exec to install Homebrew and other essential dependencies on the server: