You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/cloudflare-one/connections/connect-networks/deployment-guides/ansible.mdx
+18-72Lines changed: 18 additions & 72 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Ansible works alongside Terraform to streamline the Cloudflare Tunnel setup proc
16
16
To complete the steps in this guide, you will need:
17
17
18
18
-[A Google Cloud Project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#creating_a_project) and [GCP CLI installed and authenticated](https://cloud.google.com/sdk/docs/install).
19
-
-[Basic knowledge of Terraform](/cloudflare-one/connections/connect-networks/deployment-guides/terraform/) and[Terraform installed](https://developer.hashicorp.com/terraform/tutorials/certification-associate-tutorials/install-cli).
19
+
-[Basic knowledge of Terraform](/cloudflare-one/connections/connect-networks/deployment-guides/terraform/) and[Terraform installed](https://developer.hashicorp.com/terraform/tutorials/certification-associate-tutorials/install-cli).
20
20
-[A zone on Cloudflare](/fundamentals/setup/manage-domains/add-site/).
21
21
-[A Cloudflare API token](/fundamentals/api/get-started/create-token/) with `Cloudflare Tunnel` and `DNS` permissions.
22
22
@@ -134,47 +134,6 @@ The following configuration will modify settings in your Cloudflare account.
134
134
]
135
135
}
136
136
}
137
-
138
-
# (Optional) Routes internal IP of GCP instance through the tunnel for private network access using WARP.
@@ -248,7 +207,7 @@ The following configuration defines the specifications for the GCP virtual machi
248
207
249
208
### Export variables to Ansible
250
209
251
-
The following Terraform resource exports the tunnel ID and other variables to `tf_ansible_vars_file.yml`. Ansible will use this data to configure and run `cloudflared` on the server.
210
+
The following Terraform resource exports the [tunnel token](/cloudflare-one/connections/connect-networks/configure-tunnels/remote-tunnel-permissions/) and other variables to `tf_ansible_vars_file.yml`. Ansible will use the tunnel token to configure and run `cloudflared` on the server.
252
211
253
212
1. In your configuration directory, create a new `tf` file:
254
213
@@ -263,10 +222,8 @@ The following Terraform resource exports the tunnel ID and other variables to `t
263
222
content = <<-DOC
264
223
# Ansible vars_file containing variable values from Terraform.
- name: Create the config file for cloudflared and define the ingress rules for the tunnel.
304
-
copy:
305
-
dest: "/etc/cloudflared/config.yml"
306
-
content: |
307
-
tunnel: "{{ tunnel_id }}"
308
-
credentials-file: /etc/cloudflared/cert.json
309
-
logfile: /var/log/cloudflared.log
310
-
loglevel: info
311
-
ingress:
312
-
- hostname: "ssh_app.{{ zone }}"
313
-
service: ssh://localhost:22
314
-
- service: http_status:404
315
-
- name: Create the tunnel credentials file for cloudflared.
316
-
copy:
317
-
dest: "/etc/cloudflared/cert.json"
318
-
content: |
319
-
{
320
-
"AccountTag" : "{{ account | quote }}",
321
-
"TunnelID" : "{{ tunnel_id | quote }}",
322
-
"TunnelName" : "{{ tunnel_name | quote }}",
323
-
"TunnelSecret" : "{{ secret | quote }}"
324
-
}
325
258
- name: Install the tunnel as a systemd service.
326
-
shell: cloudflared service install
259
+
shell: "cloudflared service install {{ tunnel_token }}"
327
260
- name: Start the tunnel.
328
261
systemd:
329
262
name: cloudflared
330
263
state: started
331
264
enabled: true
332
265
masked: no
266
+
- name: Deploy an example Apache web server on port 80.
267
+
shell: apt update && apt -y install apache2
268
+
- name: Edit the default Apache index file.
269
+
copy:
270
+
dest: /var/www/html/index.html
271
+
content: |
272
+
<!DOCTYPE html>
273
+
<html>
274
+
<body>
275
+
<h1>Hello Cloudflare!</h1>
276
+
<p>This page was created for a Cloudflare demo.</p>
277
+
</body>
278
+
</html>
333
279
```
334
280
335
281
[Keywords](https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html#play) define how Ansible will execute the configuration. In the example above, the `vars_files` keyword specifies where variable definitions are stored, and the `tasks` keyword specifies the actions Ansible will perform.
@@ -362,4 +308,4 @@ It may take several minutes for the GCP instance and tunnel to come online. You
362
308
363
309
## 7. Test the connection
364
310
365
-
You can now SSH to the GCP server through the new `ssh_app.<zone>` hostname. For instructions on how to connect, refer to our [SSH guide](/cloudflare-one/connections/connect-networks/use-cases/ssh/).
311
+
To test, open a browser and go to `http://http_app.<CLOUDFLARE_ZONE>.com` (for example, `http_app.example.com`). You should see the **Hello Cloudflare!** test page.
0 commit comments