Skip to content

soundbanana/nextcloud-deployment-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nextcloud Deployment with Terraform and Ansible

This project automates the deployment of Nextcloud on a Yandex Cloud virtual machine using Terraform for infrastructure provisioning and Ansible for configuration management. The setup ensures a seamless and repeatable deployment process.


Project Setup

1. Clone the Repository:

git https://github.com/soundbanana/nextcloud-deployment-service.git
cd nextcloud-deployment-service

2. Initialize Terraform:

Run the following command to initialize Terraform and download the required providers:

terraform init

3. Run the following command to get your Cloud ID

yc resource-manager cloud list

4. Run the following command to get keys for your Yandex Cloud Service Account:

yc iam key create --service-account-name {your-sa-name} --output ../path/to/keys.json

5. Configure Variables:

Update the terraform.tfvars file with your Yandex Cloud credentials and other required variables. Example:

CLOUD_ID = "your-cloud-id"
FOLDER_ID = "your-folder-id"
SERVICE_ACCOUNT_KEY_FILE_PATH = "../path/to/keys.json"

Deployment Instructions

1. Apply the Terraform Configuration:

Deploy the infrastructure and configure the server using Ansible:

cd terraform
terraform init
terraform apply

Terraform will:

  • Provision a virtual machine on Yandex Cloud.
  • Automatically install Ansible if it is not already installed.
  • Add the server's IP address to the SSH known_hosts file.
  • Run the Ansible playbook to install and configure Nextcloud.

2. Verify the Output:

After the deployment is complete, Terraform will output the URL and DNS address of the server. Example:

dns = "http://project.vvot39.itiscl.ru./nextcloud/index.php"
url = "http://130.193.59.233/nextcloud/index.php"

Destroying Resources

To tear down the infrastructure and remove all resources, run:

terraform destroy

This will:

  • Delete the virtual machine.
  • Remove all associated resources (e.g., network, disk).

Ansible Installation Guide

If Ansible is not installed, the Terraform script will attempt to install it automatically. If the automatic installation fails, you can install Ansible manually using the appropriate package manager for your system.


Ubuntu/Debian

Run the following commands to install Ansible on Ubuntu or Debian-based systems:

sudo apt update
sudo apt install ansible -y

CentOS/RHEL

Run the following commands to install Ansible on CentOS or RHEL-based systems:

sudo yum install ansible -y

macOS

If you are using macOS, you can install Ansible via Homebrew:

brew install ansible

Notes

  • Automatic Ansible Installation: The Terraform script includes a step to automatically install Ansible if it is not already present on your system.

  • Retry Mechanism: The script includes a retry mechanism for adding the server to the known_hosts file. If it fails, simply re-run terraform apply.

  • DNS Configuration: If you are using a custom DNS, ensure that the DNS records are correctly configured before accessing Nextcloud.

Contributing

If you would like to contribute to this project, feel free to open an issue or submit a pull request. Your contributions are welcome!

Screenshots: Running Server

About

Nextcloud Deployment with Terraform and Ansible

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published