|
35 | 35 | [module sources](https://developer.hashicorp.com/terraform/language/modules/sources)
|
36 | 36 | in the Terraform documentation.
|
37 | 37 |
|
38 |
| -## Git authentication |
| 38 | +## Coder modules |
| 39 | + |
| 40 | +Coder publishes plenty of modules that can be used to simplify some common tasks |
| 41 | +across templates. Some of the modules we publish are, |
| 42 | + |
| 43 | +1. [`code-server`](https://registry.coder.com/modules/code-server) and |
| 44 | + [`vscode-web`](https://registry.coder.com/modules/vscode-web) |
| 45 | +2. [`git-clone`](https://registry.coder.com/modules/git-clone) |
| 46 | +3. [`dotfiles`](https://registry.coder.com/modules/dotfiles) |
| 47 | +4. [`jetbrains-gateway`](https://registry.coder.com/modules/jetbrains-gateway) |
| 48 | +5. [`jfrog-oauth`](https://registry.coder.com/modules/jfrog-oauth) and |
| 49 | + [`jfrog-token`](https://registry.coder.com/modules/jfrog-token) |
| 50 | +6. [`vault-github`](https://registry.coder.com/modules/vault-github) |
| 51 | + |
| 52 | +For a full list of available modules please check |
| 53 | +[Coder module registry](https://registry.coder.com/modules). |
| 54 | + |
| 55 | +## Offline installations |
| 56 | + |
| 57 | +In offline and restricted deploymnets, there are 2 ways to fetch modules. |
| 58 | + |
| 59 | +1. Artifactory |
| 60 | +2. Private git repository |
| 61 | + |
| 62 | +### Artifactory |
| 63 | + |
| 64 | +Air gapped users can clone the [coder/modules](htpps://github.com/coder/modules) |
| 65 | +repo and publish a |
| 66 | +[local terraform module repository](https://jfrog.com/help/r/jfrog-artifactory-documentation/set-up-a-terraform-module/provider-registry) |
| 67 | +to resolve modules via [Artifactory](https://jfrog.com/artifactory/). |
| 68 | + |
| 69 | +1. Create a local-terraform-repository with name `coder-modules-local` |
| 70 | +2. Create a virtual repository with name `tf` |
| 71 | +3. Follow the below instructions to publish coder modules to Artifactory |
| 72 | + |
| 73 | + ```shell |
| 74 | + git clone https://github.com/coder/modules |
| 75 | + cd modules |
| 76 | + jf tfc |
| 77 | + jf tf p --namespace="coder" --provider="coder" --tag="1.0.0" |
| 78 | + ``` |
| 79 | + |
| 80 | +4. Generate a token with access to the `tf` repo and set an `ENV` variable |
| 81 | + `TF_TOKEN_example.jfrog.io="XXXXXXXXXXXXXXX"` on the Coder provisioner. |
| 82 | +5. Create a file `.terraformrc` with following content and mount at |
| 83 | + `/home/coder/.terraformrc` within the Coder provisioner. |
| 84 | + |
| 85 | + ```hcl |
| 86 | + provider_installation { |
| 87 | + direct { |
| 88 | + exclude = ["registry.terraform.io/*/*"] |
| 89 | + } |
| 90 | + network_mirror { |
| 91 | + url = "https://example.jfrog.io/artifactory/api/terraform/tf/providers/" |
| 92 | + } |
| 93 | + } |
| 94 | + ``` |
| 95 | + |
| 96 | +6. Update module source as, |
| 97 | + |
| 98 | + ```hcl |
| 99 | + module "module-name" { |
| 100 | + source = "https://example.jfrog.io/tf__coder/module-name/coder" |
| 101 | + version = "1.0.0" |
| 102 | + agent_id = coder_agent.example.id |
| 103 | + ... |
| 104 | + } |
| 105 | + ``` |
| 106 | + |
| 107 | +> Do not forget to replace example.jfrog.io with your Artifactory URL |
| 108 | +
|
| 109 | +Based on the instructions |
| 110 | +[here](https://jfrog.com/blog/tour-terraform-registries-in-artifactory/). |
| 111 | + |
| 112 | +#### Example template |
| 113 | + |
| 114 | +We have an example template [here](../../examples/jfrog/remote/main.tf) that |
| 115 | +uses our [JFrog Docker](../../examples/jfrog/docker/main.tf) template as the |
| 116 | +underlying module. |
| 117 | + |
| 118 | +### Private git repository |
39 | 119 |
|
40 | 120 | If you are importing a module from a private git repository, the Coder server or
|
41 | 121 | [provisioner](../admin/provisioners.md) needs git credentials. Since this token
|
@@ -65,7 +145,7 @@ If you are running Coder on Docker or Kubernetes, `git` is pre-installed in the
|
65 | 145 | Coder image. However, you still need to mount credentials. This can be done via
|
66 | 146 | a Docker volume mount or Kubernetes secrets.
|
67 | 147 |
|
68 |
| -### Passing git credentials in Kubernetes |
| 148 | +#### Passing git credentials in Kubernetes |
69 | 149 |
|
70 | 150 | First, create a `.gitconfig` and `.git-credentials` file on your local machine.
|
71 | 151 | You might want to do this in a temporary directory to avoid conflicting with
|
@@ -108,53 +188,12 @@ coder:
|
108 | 188 | readOnly: true
|
109 | 189 | ```
|
110 | 190 |
|
111 |
| -## Artifactory |
112 |
| -
|
113 |
| -JFrog Artifactory can serve as a Terraform module registry, allowing you to |
114 |
| -simplify a Coder-stored template to a `module` block and input variables. |
115 |
| - |
116 |
| -With this approach, you can: |
117 |
| - |
118 |
| -- Easily share templates across multiple Coder instances |
119 |
| -- Store templates far larger than the 1MB limit of Coder's template storage |
120 |
| -- Apply JFrog platform security policies to your templates |
121 |
| - |
122 |
| -### Basic Scaffolding |
123 |
| - |
124 |
| -For example, a template with: |
125 |
| - |
126 |
| -```hcl |
127 |
| -module "frontend" { |
128 |
| - source = "cdr.jfrog.io/tf__main/frontend/docker" |
129 |
| -} |
130 |
| -``` |
131 |
| - |
132 |
| -References the `frontend` module in the `main` namespace of the `tf` repository. |
133 |
| -Remember to replace `cdr.jfrog.io` with your Artifactory instance URL. |
134 |
| - |
135 |
| -You can upload the underlying module to Artifactory with: |
136 |
| - |
137 |
| -```shell |
138 |
| -# one-time setup commands |
139 |
| -# run this on the coder server (or external provisioners, if you have them) |
140 |
| -terraform login cdr.jfrog.io; jf tfc --global |
141 |
| -
|
142 |
| -# jf tf p assumes the module name is the same as the current directory name. |
143 |
| -jf tf p --namespace=main --provider=docker --tag=v0.0.1 |
144 |
| -``` |
145 |
| - |
146 |
| -### Example template |
147 |
| - |
148 |
| -We have an example template |
149 |
| -[here](https://github.com/coder/coder/tree/main/examples/jfrog/remote) that uses |
150 |
| -our [JFrog Docker](../platforms/jfrog.md) template as the underlying module. |
151 |
| - |
152 | 191 | ### Next up
|
153 | 192 |
|
154 | 193 | Learn more about
|
155 | 194 |
|
156 | 195 | - JFrog's Terraform Registry support
|
157 | 196 | [here](https://jfrog.com/help/r/jfrog-artifactory-documentation/terraform-registry).
|
158 | 197 | - Configuring the JFrog toolchain inside a workspace
|
159 |
| - [here](../platforms/jfrog.md). |
| 198 | + [here](../guides/artifactory-integration.md). |
160 | 199 | - Coder Module Registry [here](https://registry.coder.com/modules)
|
0 commit comments