Skip to content

Commit e53d8bd

Browse files
authored
docs: update modules docs (coder#11911)
1 parent 68641f9 commit e53d8bd

File tree

3 files changed

+86
-94
lines changed

3 files changed

+86
-94
lines changed

docs/changelogs/v2.1.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
[offline docs](https://www.jetbrains.com/help/idea/fully-offline-mode.html)
6363
for JetBrains Gateway (#9039) (@ericpaulsen)
6464
- Add `coder login` to CI docs (#9038) (@ericpaulsen)
65-
- Expand [JFrog platform](https://coder.com/docs/v2/latest/platforms/jfrog) and
65+
- Expand [JFrog platform](https://coder.com/docs/v2/v2.1.0/platforms/jfrog) and
6666
example template (#9073) (@matifali)
6767

6868
## Container image

docs/install/offline.md

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -232,55 +232,8 @@ accessible for your team to use.
232232

233233
## Coder Modules
234234

235-
### Artifactory
236-
237-
Air gapped users can clone the [coder/modules](htpps://github.com/coder/modules)
238-
repo and publish a
239-
[local terraform module repository](https://jfrog.com/help/r/jfrog-artifactory-documentation/set-up-a-terraform-module/provider-registry)
240-
to resolve modules via [Artifactory](https://jfrog.com/artifactory/).
241-
242-
1. Create a local-terraform-repository with name `coder-modules-local`
243-
2. Create a virtual repository with name `tf`
244-
3. Follow the below instructions to publish coder modules to Artifactory
245-
246-
```shell
247-
git clone https://github.com/coder/modules
248-
cd modules
249-
jf tfc
250-
jf tf p --namespace="coder" --provider="coder" --tag="1.0.0"
251-
```
252-
253-
4. Generate a token with access to the `tf` repo and set an `ENV` variable
254-
`TF_TOKEN_example.jfrog.io="XXXXXXXXXXXXXXX"` on the Coder provisioner.
255-
5. Create a file `.terraformrc` with following content and mount at
256-
`/home/coder/.terraformrc` within the Coder provisioner.
257-
258-
```hcl
259-
provider_installation {
260-
direct {
261-
exclude = ["registry.terraform.io/*/*"]
262-
}
263-
network_mirror {
264-
url = "https://example.jfrog.io/artifactory/api/terraform/tf/providers/"
265-
}
266-
}
267-
```
268-
269-
6. Update module source as,
270-
271-
```hcl
272-
module "module-name" {
273-
source = "https://example.jfrog.io/tf__coder/module-name/coder"
274-
version = "1.0.0"
275-
agent_id = coder_agent.example.id
276-
...
277-
}
278-
```
279-
280-
> Do not forget to replace example.jgrog.io with uour Artifactory URL
281-
282-
Based on the instructions
283-
[here](https://jfrog.com/blog/tour-terraform-registries-in-artifactory/).
235+
To Use Coder modules in offline installations please follow the instrcutiosn
236+
[here](../templates/modules.md#offline-installations).
284237

285238
## Firewall exceptions
286239

docs/templates/modules.md

Lines changed: 83 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,87 @@ and
3535
[module sources](https://developer.hashicorp.com/terraform/language/modules/sources)
3636
in the Terraform documentation.
3737

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
39119

40120
If you are importing a module from a private git repository, the Coder server or
41121
[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
65145
Coder image. However, you still need to mount credentials. This can be done via
66146
a Docker volume mount or Kubernetes secrets.
67147

68-
### Passing git credentials in Kubernetes
148+
#### Passing git credentials in Kubernetes
69149

70150
First, create a `.gitconfig` and `.git-credentials` file on your local machine.
71151
You might want to do this in a temporary directory to avoid conflicting with
@@ -108,53 +188,12 @@ coder:
108188
readOnly: true
109189
```
110190
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-
152191
### Next up
153192
154193
Learn more about
155194
156195
- JFrog's Terraform Registry support
157196
[here](https://jfrog.com/help/r/jfrog-artifactory-documentation/terraform-registry).
158197
- Configuring the JFrog toolchain inside a workspace
159-
[here](../platforms/jfrog.md).
198+
[here](../guides/artifactory-integration.md).
160199
- Coder Module Registry [here](https://registry.coder.com/modules)

0 commit comments

Comments
 (0)