Skip to content

Commit

Permalink
first documentation round
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwassiljew committed Sep 30, 2024
1 parent 6c92cca commit e3d2f38
Show file tree
Hide file tree
Showing 12 changed files with 1,437 additions and 60 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,5 @@ node_modules/
**/.vitepress/dist

**TODO*

*export.json*
69 changes: 69 additions & 0 deletions iac/ansible/export-vaultwarden-vault.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
- name: Get Vaultwarden server version
hosts: localhost
gather_facts: false
vars:
vaultwarden_server: '{{ VAULTWARDEN_SERVER }}' # Replace with actual server or pass as extra var

username: "{{ USERNAME }}" # Set via external variables or replace
password: "{{ PASSWORD }}" # Set via external variables or replace
vaultwarden_export_json: "{{ VAULTWARDEN_EXPORT_JSON }}" # Path for exported JSON

tasks:
- name: Fetch Vaultwarden config
ansible.builtin.uri:
url: '{{ vaultwarden_server }}/api/config'
return_content: true
status_code: 200
register: response
failed_when: response.status != 200

- name: Parse and extract server version
ansible.builtin.set_fact:
server_version: "{{ response.json | json_query('server.version') }}"

- name: Debug output
ansible.builtin.debug:
var: server_version

- name: Set Bitwarden server
ansible.builtin.command:
cmd: bw config server "{{ vaultwarden_server }}"

- name: Log in to Bitwarden and export session token
ansible.builtin.command:
cmd: bw login "{{ username }}" "{{ password }}" --raw
register: bw_session
changed_when: false

- name: Export session token to environment variable
ansible.builtin.set_fact:
BW_SESSION: "{{ bw_session.stdout }}"

- name: Sync Bitwarden data
ansible.builtin.command:
cmd: bw sync
environment:
BW_SESSION: "{{ BW_SESSION }}"

- name: Export Vaultwarden data in JSON format
ansible.builtin.command:
cmd: bw export --format json --output "{{ vaultwarden_export_json }}"
environment:
BW_SESSION: "{{ BW_SESSION }}"

- name: Log out from Vaultwarden
ansible.builtin.command:
cmd: bw logout
environment:
BW_SESSION: "{{ BW_SESSION }}"

- name: Validate JSON content using Ansible's built-in filter
ansible.builtin.slurp:
path: "{{ vaultwarden_export_json }}"
register: json_file_content

- name: Parse and validate JSON
set_fact:
parsed_json: "{{ json_file_content.content | b64decode | from_json }}"
failed_when: parsed_json is not defined
69 changes: 69 additions & 0 deletions iac/ansible/export-vaultwarden.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
- name: Get Vaultwarden server version
hosts: localhost
gather_facts: false
vars:
vaultwarden_server: '{{ VAULTWARDEN_SERVER }}' # Replace with actual server or pass as extra var

username: "{{ USERNAME }}" # Set via external variables or replace
password: "{{ PASSWORD }}" # Set via external variables or replace
vaultwarden_export_json: "{{ VAULTWARDEN_EXPORT_JSON }}" # Path for exported JSON

tasks:
- name: Fetch Vaultwarden config
ansible.builtin.uri:
url: '{{ vaultwarden_server }}/api/config'
return_content: true
status_code: 200
register: response
failed_when: response.status != 200

- name: Parse and extract server version
ansible.builtin.set_fact:
server_version: "{{ response.json | json_query('server.version') }}"

- name: Debug output
ansible.builtin.debug:
var: server_version

- name: Set Bitwarden server
ansible.builtin.command:
cmd: bw config server "{{ vaultwarden_server }}"

- name: Log in to Bitwarden and export session token
ansible.builtin.command:
cmd: bw login "{{ username }}" "{{ password }}" --raw
register: bw_session
changed_when: false

- name: Export session token to environment variable
ansible.builtin.set_fact:
BW_SESSION: "{{ bw_session.stdout }}"

- name: Sync Bitwarden data
ansible.builtin.command:
cmd: bw sync
environment:
BW_SESSION: "{{ BW_SESSION }}"

- name: Export Vaultwarden data in JSON format
ansible.builtin.command:
cmd: bw export --format json --output "{{ vaultwarden_export_json }}"
environment:
BW_SESSION: "{{ BW_SESSION }}"

- name: Log out from Vaultwarden
ansible.builtin.command:
cmd: bw logout
environment:
BW_SESSION: "{{ BW_SESSION }}"

- name: Validate JSON content using Ansible's built-in filter
ansible.builtin.slurp:
path: "{{ vaultwarden_export_json }}"
register: json_file_content

- name: Parse and validate JSON
set_fact:
parsed_json: "{{ json_file_content.content | b64decode | from_json }}"
failed_when: parsed_json is not defined
23 changes: 23 additions & 0 deletions iac/ansible/get-vaultwarden-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
- name: Get Vaultwarden server version
hosts: localhost
gather_facts: false
vars:
vaultwarden_server: '{{ VAULTWARDEN_SERVER }}' # Replace with actual server or pass as extra var

tasks:
- name: Fetch Vaultwarden config
ansible.builtin.uri:
url: '{{ vaultwarden_server }}/api/config'
return_content: true
status_code: 200
register: response
failed_when: response.status != 200

- name: Parse and extract server version
ansible.builtin.set_fact:
server_version: "{{ response.json | json_query('server.version') }}"

- name: Debug output
ansible.builtin.debug:
var: server_version
13 changes: 13 additions & 0 deletions iac/ansible/main_playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
- name: Get Vaultwarden server version
import_playbook: get-vaultwarden-version.yaml

- name: Export Vaultwarden
import_playbook: export-vaultwarden.yaml

- hosts: localhost
gather_facts: no
tasks:
- name: Capture output from Playbook 1
set_fact:
server_version: "{{ server_version }}"
18 changes: 18 additions & 0 deletions iac/ansible/playbook2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Playbook 2 - Use output from Playbook 1
hosts: localhost
gather_facts: no
vars:
number_from_playbook1: ""
tasks:
- name: Use the random number passed from Playbook 1
debug:
msg: "Using the number from Playbook 1: {{ number_from_playbook1 }}"

- name: Perform a task using the passed number (Simulated task)
ansible.builtin.command: "echo Processing number {{ number_from_playbook1 }}"
register: processed_output

- name: Display processed output
debug:
msg: "Processed output is: {{ processed_output.stdout }}"
124 changes: 67 additions & 57 deletions pages/docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,62 +1,72 @@
import { defineConfig } from 'vitepress'
import { withMermaid } from "vitepress-plugin-mermaid";

// https://vitepress.dev/reference/site-config
export default defineConfig({
title: "Rocket Cloud",
description: "Documentation",
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: 'Home', link: '/' },
{ text: 'Getting started', link: '/getting-started' }
],

sidebar: [
{
text: 'How it works',
items: [
{ text: 'Concepts', link: '/how-it-works' },
]
},
{
text: 'Getting started',
items: [
]
},
{
text: 'Development',
items: [
{ text: 'Principles & Guidelines', link: '/principles-and-guidelines' },
]
},
{
text: 'Applicaitons & Services',
items: [
{ text: 'Docs (vitepress)', link: '/apps/docs' },
{ text: 'Homer', link: '/apps/homer' },
{ text: 'Status (upptime)', link: '/apps/status' },
{ text: 'Vault', link: '/apps/vault' },
{ text: 'Vaultwarden', link: '/apps/vaultwarden' },
]
},
{
text: '',
items: [
{ text: 'Server rack', link: '/rack' },
{ text: 'Evolution of the homelab', link: '/evolution' },
]
},
{
text: 'Examples',
items: [
{ text: 'Markdown Examples', link: '/markdown-examples' },
{ text: 'Runtime API Examples', link: '/api-examples' }
]
}
],
export default withMermaid(
defineConfig({
title: "Rocket Cloud",
description: "Documentation",
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: 'Home', link: '/' },
{ text: 'Getting started', link: '/getting-started' }
],

socialLinks: [
{ icon: 'github', link: 'https://github.com/tryrocket-cloud/home-ops' }
]
}
})
sidebar: [
{
text: 'How it works',
items: [
{ text: 'Concepts', link: '/how-it-works' },
]
},
{
text: 'Getting started',
items: [
]
},
{
text: 'Development',
items: [
{ text: 'Principles & Guidelines', link: '/principles-and-guidelines' },
]
},
{
text: 'Applicaitons & Services',
items: [
{ text: 'Docs (vitepress)', link: '/apps/docs' },
{ text: 'Homer', link: '/apps/homer' },
{ text: 'Status (upptime)', link: '/apps/status' },
{ text: 'Vault', link: '/apps/vault' },
{ text: 'Vaultwarden', link: '/apps/vaultwarden' },
]
},
{
text: 'Administarion',
items: [
{ text: 'Backup', link: 'backup-general' },
]
},
{
text: '',
items: [
{ text: 'Server rack', link: '/rack' },
{ text: 'Evolution of the homelab', link: '/evolution' },
]
},
{
text: 'Examples',
items: [
{ text: 'Markdown Examples', link: '/markdown-examples' },
{ text: 'Runtime API Examples', link: '/api-examples' }
]
}
],

socialLinks: [
{ icon: 'github', link: 'https://github.com/tryrocket-cloud/home-ops' }
]
}
})
)
7 changes: 7 additions & 0 deletions pages/docs/apps/vault.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ outline: deep
# Vault

https://vault.tryrocket.cloud

Type: `critical`

Backups:

- export
- data
18 changes: 18 additions & 0 deletions pages/docs/apps/vaultwarden.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,21 @@ outline: deep
# Vaultwarden

https://vaultwarden.tryrocket.cloud

## Backup and Restore

### Export

```sh
ansible-playbook vaultwarden-export-backup.yaml -e "VAULTWARDEN_SERVER=https://vaultwarden.tryrocket.cloud"
# or
ansible-playbook vaultwarden-export-kopia.yaml -e "VAULTWARDEN_SERVER=https://vaultwarden.tryrocket.cloud"
ansible-playbook vaultwarden-export-restic.yaml -e "VAULTWARDEN_SERVER=https://vaultwarden.tryrocket.cloud"
```

Type: `critical`

Backups:

- export
- data
Loading

0 comments on commit e3d2f38

Please sign in to comment.