Ping Pools bevor deploy ausgeführt wird
This commit is contained in:
parent
005a4e2344
commit
61bc08b4d7
2 changed files with 56 additions and 9 deletions
|
@ -1,6 +1,8 @@
|
||||||
stages:
|
stages:
|
||||||
- lint
|
- lint
|
||||||
|
- ping-test
|
||||||
- deploy-test
|
- deploy-test
|
||||||
|
- ping-prod
|
||||||
- deploy-prod
|
- deploy-prod
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
|
@ -24,7 +26,7 @@ markdown-lint:
|
||||||
stage: lint
|
stage: lint
|
||||||
image: pipelinecomponents/markdownlint:latest
|
image: pipelinecomponents/markdownlint:latest
|
||||||
script:
|
script:
|
||||||
- mdl --style all --warnings .
|
- mdl --style all --warnings --rules ~MD022,~MD013 .
|
||||||
interruptible: true
|
interruptible: true
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
rules:
|
rules:
|
||||||
|
@ -32,6 +34,25 @@ markdown-lint:
|
||||||
tags:
|
tags:
|
||||||
- ansible
|
- ansible
|
||||||
|
|
||||||
|
ping-test:
|
||||||
|
image: quotengrote/gitlab-ci-ansible:latest
|
||||||
|
stage: ping-test
|
||||||
|
interruptible: true
|
||||||
|
before_script:
|
||||||
|
- chmod 0755 /builds/mg/ansible
|
||||||
|
- echo "$id_rsa_ansible_user" > /builds/mg/ansible/id_rsa_ansible_user
|
||||||
|
- chmod 0400 /builds/mg/ansible/id_rsa_ansible_user
|
||||||
|
script:
|
||||||
|
- ansible -i inventory --limit test --vault-password-file $ansible_vault_pass all -m ping
|
||||||
|
after_script:
|
||||||
|
- rm /builds/mg/ansible/id_rsa_ansible_user
|
||||||
|
rules:
|
||||||
|
- if: $CI_MERGE_REQUEST_ID
|
||||||
|
tags:
|
||||||
|
- ansible
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ansible-deploy-test:
|
ansible-deploy-test:
|
||||||
image: quotengrote/gitlab-ci-ansible:latest
|
image: quotengrote/gitlab-ci-ansible:latest
|
||||||
stage: deploy-test
|
stage: deploy-test
|
||||||
|
@ -49,6 +70,23 @@ ansible-deploy-test:
|
||||||
tags:
|
tags:
|
||||||
- ansible
|
- ansible
|
||||||
|
|
||||||
|
ping-prod:
|
||||||
|
image: quotengrote/gitlab-ci-ansible:latest
|
||||||
|
stage: ping-prod
|
||||||
|
interruptible: true
|
||||||
|
before_script:
|
||||||
|
- chmod 0755 /builds/mg/ansible
|
||||||
|
- echo "$id_rsa_ansible_user" > /builds/mg/ansible/id_rsa_ansible_user
|
||||||
|
- chmod 0400 /builds/mg/ansible/id_rsa_ansible_user
|
||||||
|
script:
|
||||||
|
- ansible -i inventory --limit production --vault-password-file $ansible_vault_pass all -m ping
|
||||||
|
after_script:
|
||||||
|
- rm /builds/mg/ansible/id_rsa_ansible_user
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_BRANCH == 'master'
|
||||||
|
tags:
|
||||||
|
- ansible
|
||||||
|
|
||||||
ansible-deploy-prod:
|
ansible-deploy-prod:
|
||||||
image: quotengrote/gitlab-ci-ansible:latest
|
image: quotengrote/gitlab-ci-ansible:latest
|
||||||
stage: deploy-prod
|
stage: deploy-prod
|
||||||
|
|
25
README.md
25
README.md
|
@ -2,21 +2,25 @@
|
||||||
|
|
||||||
[![pipeline status](http://git.mgrote.net/mg/ansible/badges/master/pipeline.svg)](http://git.mgrote.net/mg/ansible/-/commits/master)
|
[![pipeline status](http://git.mgrote.net/mg/ansible/badges/master/pipeline.svg)](http://git.mgrote.net/mg/ansible/-/commits/master)
|
||||||
|
|
||||||
|
|
||||||
## Ansible KeePass Lookup Plugin aktualisieren
|
## Ansible KeePass Lookup Plugin aktualisieren
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install 'pykeepass>3.2.0' --user
|
pip install 'pykeepass>3.2.0' --user
|
||||||
mkdir -p ~/.ansible/plugins/lookup && cd "$_"
|
mkdir -p ~/.ansible/plugins/lookup && cd "$_"
|
||||||
curl https://raw.githubusercontent.com/viczem/ansible-keepass/master/keepass.py -o ./keepass.py
|
curl https://raw.githubusercontent.com/viczem/ansible-keepass/master/keepass.py -o ./keepass.py
|
||||||
```
|
```
|
||||||
|
|
||||||
## collections als Dependency
|
## collections als Dependency
|
||||||
|
|
||||||
- in meta
|
- in meta
|
||||||
```
|
|
||||||
|
```yaml
|
||||||
collections:
|
collections:
|
||||||
- community.general
|
- community.general
|
||||||
```
|
```
|
||||||
|
|
||||||
## defaults in Dictionary
|
## defaults in Dictionary
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
- name: "register_runner"
|
- name: "register_runner"
|
||||||
community.general.gitlab_runner:
|
community.general.gitlab_runner:
|
||||||
|
@ -29,7 +33,6 @@ description: <-- Original-Variable
|
||||||
default('GitLab-Runner') }}" <-- wenn Inhalt leer, dann default...
|
default('GitLab-Runner') }}" <-- wenn Inhalt leer, dann default...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## [playbook-grapher](https://github.com/haidaraM/ansible-playbook-grapher)
|
## [playbook-grapher](https://github.com/haidaraM/ansible-playbook-grapher)
|
||||||
`ansible-playbook-grapher --include-role-tasks tests/fixtures/with_roles.yml`
|
`ansible-playbook-grapher --include-role-tasks tests/fixtures/with_roles.yml`
|
||||||
|
|
||||||
|
@ -43,7 +46,8 @@ default('GitLab-Runner') }}" <-- wenn Inhalt leer, dann default...
|
||||||
`ansible-galaxy collection list -vvv`
|
`ansible-galaxy collection list -vvv`
|
||||||
|
|
||||||
## fix ansible vault-permissions
|
## fix ansible vault-permissions
|
||||||
```
|
|
||||||
|
```bash
|
||||||
sudo chmod 400 id_rsa_ansible_user
|
sudo chmod 400 id_rsa_ansible_user
|
||||||
sudo chmod 400 vault-pass.yml
|
sudo chmod 400 vault-pass.yml
|
||||||
```
|
```
|
||||||
|
@ -60,12 +64,14 @@ Diese Datei enthält das Passwort mit dem die KeePassDb verschlüsselt ist.
|
||||||
Das vault-secret für die GroupVars wird mit `ansible-vault encrypt_string <password>` erstellt.
|
Das vault-secret für die GroupVars wird mit `ansible-vault encrypt_string <password>` erstellt.
|
||||||
|
|
||||||
### Erklärung
|
### Erklärung
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
keepass_dbx: "./keepass_db.kdbx"
|
keepass_dbx: "./keepass_db.kdbx"
|
||||||
keepass_psw: !vault |
|
keepass_psw: !vault |
|
||||||
$ANSIBLE_VAULT;1.1;AES256
|
$ANSIBLE_VAULT;1.1;AES256
|
||||||
62383737XXXXXX531
|
62383737XXXXXX531
|
||||||
```
|
```
|
||||||
|
|
||||||
1. mit vault-pass.yml wird das Kennwort an ansible-vault übergeben
|
1. mit vault-pass.yml wird das Kennwort an ansible-vault übergeben
|
||||||
2. ansible-vault entschlüsselt hiermit die Variable `keepass_psw`
|
2. ansible-vault entschlüsselt hiermit die Variable `keepass_psw`
|
||||||
3. der Inhalt der Variable wird dann an das KeePass-Lookup-Plugin übergeben was damit die KeePass-Datei öffnet
|
3. der Inhalt der Variable wird dann an das KeePass-Lookup-Plugin übergeben was damit die KeePass-Datei öffnet
|
||||||
|
@ -74,6 +80,7 @@ Das vault-secret für die GroupVars wird mit `ansible-vault encrypt_string <pass
|
||||||
`restic_repository_password: "{{ lookup('keepass', 'restic_repository_password', 'password') }}"`
|
`restic_repository_password: "{{ lookup('keepass', 'restic_repository_password', 'password') }}"`
|
||||||
|
|
||||||
#### Erklärung
|
#### Erklärung
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
restic_repository_password: <-- Ansible Variablen Name
|
restic_repository_password: <-- Ansible Variablen Name
|
||||||
lookup('keepass' <-- Aufruf Keepass-Lookup-Plugin
|
lookup('keepass' <-- Aufruf Keepass-Lookup-Plugin
|
||||||
|
@ -84,7 +91,8 @@ password <-- Feldbzeichner in KeepassDB
|
||||||
## Inventory anzeigen
|
## Inventory anzeigen
|
||||||
`ansible-inventory -i inventory --graph`
|
`ansible-inventory -i inventory --graph`
|
||||||
|
|
||||||
## Alternatives Dictionary Format:
|
## Alternatives Dictionary Format
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
zfs_pool:
|
zfs_pool:
|
||||||
- name: "ssd_vm_mirror"
|
- name: "ssd_vm_mirror"
|
||||||
|
@ -97,6 +105,7 @@ password <-- Feldbzeichner in KeepassDB
|
||||||
cron_minutes_zfs_scrub: "0"
|
cron_minutes_zfs_scrub: "0"
|
||||||
cron_hour_zfs_scrub: "23"
|
cron_hour_zfs_scrub: "23"
|
||||||
```
|
```
|
||||||
|
|
||||||
ist das gleiche wie:
|
ist das gleiche wie:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -110,6 +119,7 @@ ist das gleiche wie:
|
||||||
|
|
||||||
## Loop + Join
|
## Loop + Join
|
||||||
### Vars
|
### Vars
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
mountpoint: "/shares"
|
mountpoint: "/shares"
|
||||||
sources:
|
sources:
|
||||||
|
@ -140,6 +150,8 @@ ist das gleiche wie:
|
||||||
|
|
||||||
## prüfen ob eine Datei existiert
|
## prüfen ob eine Datei existiert
|
||||||
|
|
||||||
|
* https://stackoverflow.com/questions/35654286/how-to-check-if-a-file-exists-in-ansible
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: check if migration file exists
|
- name: check if migration file exists
|
||||||
stat:
|
stat:
|
||||||
|
@ -189,6 +201,3 @@ ist das gleiche wie:
|
||||||
state: directory
|
state: directory
|
||||||
when: not is_installed.stat.exists
|
when: not is_installed.stat.exists
|
||||||
```
|
```
|
||||||
|
|
||||||
### Siehe auch
|
|
||||||
* https://stackoverflow.com/questions/35654286/how-to-check-if-a-file-exists-in-ansible
|
|
||||||
|
|
Loading…
Reference in a new issue