Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
patcon committed Feb 7, 2021
0 parents commit 05116e0
Show file tree
Hide file tree
Showing 8 changed files with 446 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
12 changes: 12 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
octodns = "*"

[dev-packages]

[requires]
python_version = "3.8"
295 changes: 295 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# g0v.network domains

For automating management of the `g0v.network` domain via config files.

Changing or adding DNS records in `main` branach of this repository with update
the actual domain records.

Inspired by [`g0v/domain`][g0v/domain]

[g0v/domain]: https://github.com/g0v/domain

**Note:** Work in progress. Not yet functional.

## Technologies Used

- [**octoDNS.**][octodns]

[octodns]: https://github.com/octodns/octodns

## Usage

The intended way to use this repository is via pull request directly on GitHub.

(You should only need to clone this code locally in order to improve the
automation part of this repository. See Development section.)

### Create a new subdomain

Create a new YAML file, and fill it out. For example, to create
`my.example.g0v.network`, you'd create a config file with the full subdomain
name, with a key inside it for `my.example`. Like so (click through the link to
see example):

[`g0v.network./my.example.g0v.network.yaml`][new-subdomain]

[new-subdomain]: https://github.com/g0v-network/domains/new/main?filename=g0v.network./my.example.g0v.network.yaml&value=my.example%3A%0A%20%20-%20type%3A%20A%0A%20%20%20%20value%3A%0A%20%20%20%20%20%20-%20123.45.67.89

### Delete an existing subdomain

Delete a file or a specific record type within a file. Our automation will sync this deletion when it runs.

### Modify an existing subdomain

Modify an [existing file][existing]. Our automation will sync this change when it runs.

[existing]: /g0v.network./g0v.network.yaml

## Development

To contribute changes to our automation, you'll likely want to be able to run it locally. Here's what you'll need:

- Python 3
- Cloudflare account
- Cloudflare site: `g0v.network` (can "fake it", no need to actually have access to it)
- Cloudflare API token (see instructions in `sample.env`)

```
git clone https://github.com/g0v-network/domains
cd domains
brew install pipenv
pipenv install
# Copy and modify as needed with API token
cp sample.env .env
# Validate your config locally
pipenv run octodns-validate --config-file config.yaml
# Do a dry run (no changes will be made)
pipenv run octodns-sync --config-file config.yaml
# Do a REAL run (!!!)
#
# WARNING: this is destructive, and will delete any records on a domain that
# are not present in your configuration files.
pipenv run octodns-sync --config-file config.yaml --doit
```

## :muscle: Contributing

Please open an issue or pull request in order to apply for a new subdomain.

## :copyright: License

[CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/)
22 changes: 22 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
manager:
max_workers: 2

providers:
config-files:
class: octodns.provider.yaml.SplitYamlProvider
directory: .
default_ttl: 120
enforce_order: false
# Error when dups found
populate_should_replace: false
cloudflare:
class: octodns.provider.cloudflare.CloudflareProvider
token: env/CLOUDFLARE_API_TOKEN

zones:
g0v.network.:
sources:
- config-files
targets:
- cloudflare
15 changes: 15 additions & 0 deletions g0v.network./g0v.network.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'':
- type: A
value: 162.247.75.222
octodns:
cloudflare:
proxied: true
metdata:
repository: https://github.com/g0v-network/g0v.network
maintainer:
- patcon
- type: MX
value:
exchange: erica.mayfirst.org.
preference: 0
11 changes: 11 additions & 0 deletions g0v.network./training.g0v.network.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
training:
type: CNAME
value: trainingg0vnetwork.netlify.com.
octodns:
cloudflare:
proxied: true
metadata:
repo: https://github.com/g0v-network/training.g0v.network
maintainer:
- patcon
4 changes: 4 additions & 0 deletions sample.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# See: https://support.cloudflare.com/hc/en-us/articles/200167836-Managing-API-Tokens-and-Keys
# Create a token from the template: "Edit zone DNS"
# We advise scoping it only specific domains you wish to manage via this automation.
CLOUDFLARE_API_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

0 comments on commit 05116e0

Please sign in to comment.