diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b902a0e4fa480f55fc52f2b9b1dfc223016efd3a..f7316157181b943e6f542dcead4db15bf31ef503 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -64,7 +64,7 @@ create-vps: fi # Delete old machine if it still exists python3 -c "import greenhost_cloud; greenhost_cloud.terminate_droplets_by_name(\"^${HOSTNAME}$\")" - python3 -m openappstack $HOSTNAME create --create-droplet $DOMAIN --create-hostname $HOSTNAME --ssh-key-id $SSH_KEY_ID --create-domain-records --subdomain $SUBDOMAIN + python3 -m openappstack $HOSTNAME create --acme-staging --create-droplet $DOMAIN --create-hostname $HOSTNAME --ssh-key-id $SSH_KEY_ID --create-domain-records --subdomain $SUBDOMAIN artifacts: paths: - clusters diff --git a/docs/installation_instructions.md b/docs/installation_instructions.md index 7da2b83dade7192e944f83725f33f2013f407572..76ea2cc970b3d7ef6ac39d5e87cdfd0b5c6a74a7 100644 --- a/docs/installation_instructions.md +++ b/docs/installation_instructions.md @@ -161,12 +161,13 @@ There are two options to create a cluster: - Here is an example of a complete creation command: ``` - $ python -m openappstack my-cluster create --create-droplet --hostname oas.example.org --ssh-key-id 112 --acme-live-environment --create-domain-records --subdomain oas example.org + $ python -m openappstack my-cluster create --create-droplet --hostname oas.example.org --ssh-key-id 112 --create-domain-records --subdomain oas example.org ``` - > **NOTE:** We use the `--acme-live-environment` argument. This ensures you - > get real (instead of "staging") Let's Encrypt TLS certificates. This is - > necessary for ONLYOFFICE integration to work. + > **NOTE:** You can use the `--acme-staging` argument for testing purposes + > This ensures you use "staging" certificates from Let's Encrypt, to reduce + > the stress on their servers. However, ONLYOFFICE integration requires valid + > (live) certificates to work. This will create configuration files for a cluster named `my-cluster`. It will also create a Greenhost VPS with the hostname `oas.example.org` and on @@ -184,19 +185,20 @@ If you want to follow this step, we assume you already have a VPS. You'll need its *hostname* and its *IP address*. Also check that your VPS meets our [prerequisites](#prerequisites). -> **WARNING:** the OpenAppStack installation makes substantial changes to your -> whole VPS and needs root access. It is not advised to follow these -> instructions on a VPS that you are using for something else too. +> **NOTE:** You can use the `--acme-staging` argument for testing purposes This +> ensures you use "staging" certificates from Let's Encrypt, to reduce the +> stress on their servers. However, ONLYOFFICE integration requires valid (live) +> certificates to work. Create the OpenAppStack settings for your VPS by running the following command: ``` -$ python -m openappstack my-cluster create --ip-address IP_ADDRESS --hostname HOSTNAME --subdomain oas example.org --acme-live-environment +$ python -m openappstack my-cluster create --ip-address IP_ADDRESS --hostname HOSTNAME --subdomain oas example.org ``` -> **NOTE:** We use the `--acme-live-environment` argument. This ensures you get -> real (instead of "staging") Let's Encrypt TLS certificates. This is necessary -> for ONLYOFFICE integration to work. +> **NOTE:** If you are automating this, please add the --acme-staging` +> argument. This ensures you use "staging" certificates from Let's Encrypt, to +> reduce the stress on their servers. ### DNS entries diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 5c2572caf24cbecd9d906f95fcee0e1a480cfd95..45bad692c4474b6fa6eac48e6020cf3c3c783b2f 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -10,7 +10,7 @@ services. If you experience invalid SSL certificates (i.e. your browser warns yo when visiting Nextcloud (`https://files.YOUR.CLUSTER.DOMAIN`) here's how to debug this: -Did you create your cluster using the `--acme-live-environment` argument ? +Did you create your cluster using the `--acme-staging` argument? Please check the resulting value of the `acme_staging` key in `clusters/YOUR_CLUSTERNAME/settings.yml`. If this is set to `true`, certificates are fetched from the [Let's Encrypt staging API](https://letsencrypt.org/docs/staging-environment/), diff --git a/openappstack/__main__.py b/openappstack/__main__.py index ecd78c51600502040e6961b5f56b4759ae3b3b4a..42284ab1d75ccad545a5ecec9dc1ef320a65065a 100755 --- a/openappstack/__main__.py +++ b/openappstack/__main__.py @@ -115,10 +115,10 @@ def main(): # pylint: disable=too-many-statements,too-many-branches,too-many-lo 'Defaults to no subdomain')) droplet_creation_group.add_argument( - '--acme-live-environment', + '--acme-staging', action='store_true', - help=("Use this for production clusters. Uses live Let's Encrypt " - 'environment instead of staging')) + help=("Use this for development clusters. Uses Let's Encrypt's " + 'staging environment')) install_parser = subparsers.add_parser( 'install', @@ -244,8 +244,8 @@ def create(clus, args): # pylint: disable=too-many-branches clus.domain = domain # Set acme_staging to False so we use Let's Encrypt's live environment - if args.acme_live_environment: - clus.acme_staging = False + if args.acme_staging: + clus.acme_staging = True if args.create_droplet: clus.create_droplet(ssh_key_id=args.ssh_key_id, hostname=args.create_hostname) if args.verbose: diff --git a/openappstack/ansible.py b/openappstack/ansible.py index aa1e6ec9381554f8f4c9088baf9702646b742383..01702e509452b3c8743ef650eb7c326a29e5d85f 100644 --- a/openappstack/ansible.py +++ b/openappstack/ansible.py @@ -82,4 +82,5 @@ def create_inventory(cluster): log.debug(file_contents) with open(cluster.inventory_file, 'w') as stream: stream.write(file_contents) + log.info("Created %s", cluster.inventory_file) return inventory diff --git a/openappstack/cluster.py b/openappstack/cluster.py index 21cf76e27c25b63dc54055043311b5e7b1428ee0..51cf07f4f49b1fbd28d0bfae6677acd08cc9f4a6 100644 --- a/openappstack/cluster.py +++ b/openappstack/cluster.py @@ -39,8 +39,8 @@ class Cluster: self.ip_address = None self.hostname = None self.domain = None - # By default, use Let's Encrypt's staging environment - self.acme_staging = True + # By default, use Let's Encrypt's live environment + self.acme_staging = False # Set this to False if the data needs to be (re)loaded from file self.data_loaded = False # Load data from inventory.yml and settings.yml @@ -82,16 +82,13 @@ class Cluster: Uses the Cosmos API to create a droplet with OAS default spec :param int ssh_key_id: SSH key ID in Greenhost Cosmos. - :param str hostname: hostname of the droplet created at GH. - If not provided, a hostname will be auto-generated. + :param str hostname: hostname of the droplet created at GH. Defaults to + the cluster name """ if hostname is None: # Use random generated ID in case we're not running in # gitlab CI and there's no CI_PIPELINE_ID env var - hostname = ''.join( - random.choice(string.ascii_lowercase + string.digits) - for _ in range(10)) - log.info('Generated hostname %s', hostname) + hostname = self.name droplet = cosmos.create_droplet( name=hostname, ssh_key_id=ssh_key_id, @@ -156,6 +153,7 @@ class Cluster: log.debug(file_contents) with open(self.settings_file, 'w') as stream: stream.write(file_contents) + log.info("Created %s", self.settings_file) # Set self.data_loaded to True because the data in the class now # reflects the data in the file.