Forem Creators and Builders

loading...
Cover image for Forem Google Cloud Setup on MacOS
Forem Core Team

Forem Google Cloud Setup on MacOS

Christina Gorton
Developer Advocate, Technical Writer, and Instructor.
Updated on ・4 min read

Before starting this tutorial please go through the Quick Start in Depth guide.

This is a walkthrough of the Google Cloud provider section of our selfhost repository.

To set up a Forem on Google Cloud, you must first create an account. Navigate to the
Google Cloud Homepage and fill in the appropriate information to create your account.

Install Requirements

  1. In your terminal make sure you are in the selfhost directory with: cd selfhost
  2. Install the Ansible Google Cloud collections with: ansible-galaxy collection install google.cloud or install all collections with: ansible-galaxy collection install -r requirements.yml
  3. Install requests and google-auth pip modules with: pip3 install requests google-auth

Google Cloud Service Account

You will need to set up a Google Cloud Service Account and add privileges

1.) Open the Service accounts page.

2.) Click Create Project
Create a project

3.) In the Project name field add the name forem-selfhost and click the CREATE button.
Naming and creating the project

Adding Privileges

1.) Select the newly created project from the Select Project dropdown.
Selected newly created project

2.) Click the IAM & Admin link in the side menu.
IAM & Admin link

3.) Setting up Roles

  • Navigate to the Roles link in the side menu.
  • In the filter search bar type Computer Instance Admin and choose the v1 option
  • Check the box to add the Computer Instance Admin (v1) role to the forem-selfhost Adding roles

JSON Credentials File

1.) Navigate back to the home page of your current project.

  • Hover over the APIs & Services side menu link and click the Credentials link in the dropdown menu. Click Credentials link

2.) On the Credentials page click the + Create Credentials link and select Service Account
select service account

3.) Give your service a name and add a description of what the service does.
Then click Create and Continue
Add service name and click create and continue

4.) Add at least the Owner role to the "Grant this service account access to project. Then click Done.
Grant owner role

5.) Under the Credentials page you should now see your newly created credentials under Service Accounts. Click on the newly created service account.
Click the created service account

6.) Navigate to the Keys tab and click the ADD KEY and Create new key link.
Create new key

7.) Select the JSON key type and click CREATE. The json file will then be downloaded to your computer.
Select the JSON radio button

8.) Find the name of your downloaded file and place it in ~/.gcp/forem.json.

First create a directory on your computer called ~/.gcp with the following command:

mkdir ~/.gcp
Enter fullscreen mode Exit fullscreen mode

Then move the dowloaded json file to ~/.gcp with the following command:

mv ~/my_gcp_forem.json ~/.gcp/forem.json
Enter fullscreen mode Exit fullscreen mode

You can check to see if the file is in the correct place with the following commands:
cd ~/.gcp to navigate to the directory

ls to list what files are in the directory.

You should see your forem.json file listed in the ~/.gcp directory.

Now you are ready to run your ansible playbook.

Provision

  1. In your terminal type: ansible-playbook -i inventory/forem/setup.yml playbooks/providers/gcp.yml

Note: If you run into the following error:
Botocore error
... try using this command in your terminal instead:

ansible-playbook -i inventory/forem/setup.yml playbooks/providers/gcp.yml -e ansible_python_interpreter=/usr/local/bin/python3

  1. Once you run the command, you should see an output in your terminal similar to the code below with your community's domain name and IP address. Playbook output for newly created community

DNS

  1. You will need to create an A record and point DNS at the IP address that is output at the end of the provider playbook.

You can see an example of how I set an A record for my namecheap domain below:

In Advanced DNS I added an A record for my domain and subdomain and set the value to the IP address that was outputted after provisioning. I also set TTL to 1minute.
This will defer depending on where your DNS is hosted.
Advanced DNS on namecheap.com

Forem Traefik Service

Once DNS is pointed at your Forem VM, you will need to restart the Forem Traefik service.

  1. You will need to run the command via SSH. In your terminal type: ssh core@<SERVER IP ADDRESS> replacing with your community name. In the example below I am using my community: SSH to server example
  2. You may be prompted to continue. Type yes in to your terminal.
  3. Once you have connected to your Forem server, type the following command:
    sudo systemctl restart forem-traefik.service
    sudo systemctl restart command)

  4. Now, you can navigate to your community domain and you should see a "Let's Start your Forem Journey" page. You may need to wait a few minutes after running the Forem Traefik command.
    Let's Start your Forem Journey page

Congratulations on setting up your first Forem!🎉

For more details on how to configure your Forem please visit our Forem Admin Docs.

Discussion (0)