Skip to content

Commit 3aa296c

Browse files
committed
📝 docs: Add README info about Gitlab
1 parent 241c1dd commit 3aa296c

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

.gitlab/tailscale-acls-gitops.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ validate tailscale acls:
66
script:
77
- gitops-pusher --policy-file=${TAILSCALE_POLICY_FILE:-policy.hujson} test
88

9-
push:
9+
push tailscale policy:
1010
needs:
1111
- validate tailscale acls
1212
script:

README.md

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,42 @@
1-
# GitHub Action to Sync Tailscale ACLs
1+
# CI/CD config files to Sync Tailscale ACLs
22

3-
This GitHub action lets you manage your [tailnet policy file](https://tailscale.com/kb/1018/acls/) using a
3+
These configuration files let you manage your [tailnet policy file](https://tailscale.com/kb/1018/acls/) using a
44
[GitOps](https://about.gitlab.com/topics/gitops/) workflow. With this GitHub
55
action you can automatically manage your tailnet policy file using a git repository
6-
as your source of truth.
6+
as your source of truth.
77

8-
## Inputs
8+
## Github Action
99

10-
### `tailnet`
10+
### Inputs
11+
12+
#### `tailnet`
1113

1214
**Required** The name of your tailnet. You can find it by opening [the admin
1315
panel](https://login.tailscale.com/admin) and copying down the name next to the
1416
Tailscale logo in the upper left hand corner of the page.
1517

16-
### `api-key`
18+
#### `api-key`
1719

1820
**Required** An API key authorized for your tailnet. You can get one [in the
1921
admin panel](https://login.tailscale.com/admin/settings/keys).
2022

2123
Please note that API keys will expire in 90 days. Set up a monthly event to
2224
rotate your Tailscale API key.
2325

24-
### `policy-file`
26+
#### `policy-file`
2527

2628
**Optional** The path to your policy file in the repository. If not set this
2729
defaults to `policy.hujson` in the root of your repository.
2830

29-
### `action`
31+
#### `action`
3032

3133
**Required** One of `test` or `apply`. If you set `test`, the action will run
3234
ACL tests and not update the ACLs in Tailscale. If you set `apply`, the action
3335
will run ACL tests and then update the ACLs in Tailscale. This enables you to
3436
use pull requests to make changes with CI stopping you from pushing a bad change
3537
out to production.
3638

37-
## Getting Started
39+
### Getting Started
3840

3941
Set up a new GitHub repository that will contain your tailnet policy file. Open the [Access Controls page of the admin console](https://login.tailscale.com/admin/acls) and copy your policy file to
4042
a file in that repo called `policy.hujson`.
@@ -49,9 +51,9 @@ name: Sync Tailscale ACLs
4951

5052
on:
5153
push:
52-
branches: [ "main" ]
54+
branches: ["main"]
5355
pull_request:
54-
branches: [ "main" ]
56+
branches: ["main"]
5557

5658
jobs:
5759
acls:
@@ -87,6 +89,21 @@ jobs:
8789
action: test
8890
```
8991
92+
## Gitlab CI
93+
94+
You can include the YAML file contained in this repository:
95+
96+
```yaml
97+
include:
98+
- remote: "https://raw.githubusercontent.com/rdbisme/gitops-acl-action/gitlab/.gitlab/tailscale-acls-gitops.yml"
99+
```
100+
101+
This will generate two jobs. The first one (`validate tailscale acls`) tests the validity of the ACLs policy file (by default `policy.hujson`, but can be overridden by the env variable `TAILSCALE_POLICY_FILE`). It does it for every push. The next one (`push tailscale policy`) pushes the policies upstream.
102+
103+
You can check this example project for future information: [tailscale-gitops-gitlab-example](https://gitlab.com/rdb-is/devops/tailscale-gitops-gitlab-example)
104+
105+
## Generate the required API keys
106+
90107
Generate a new API key [here](https://login.tailscale.com/admin/settings/keys).
91108

92109
Set a monthly calendar reminder to renew this key because Tailscale does not
@@ -95,8 +112,8 @@ that feature is implemented).
95112

96113
Then open the secrets settings for your repo and add two secrets:
97114

98-
* `TS_API_KEY`: Your Tailscale API key from the earlier step
99-
* `TS_TAILNET`: Your tailnet's name (it's next to the logo on the upper
115+
- `TS_API_KEY`: Your Tailscale API key from the earlier step
116+
- `TS_TAILNET`: Your tailnet's name (it's next to the logo on the upper
100117
left-hand corner of the [admin
101118
panel](https://login.tailscale.com/admin/machines))
102119

0 commit comments

Comments
 (0)