Compare commits

...

9 commits

Author SHA1 Message Date
Víðir Valberg Guðmundsson 5d0c913c2a Add ssl_certs_enabled variable and use it to avoid ssl certs when running on vagrant 2022-11-15 23:05:52 +01:00
Sam A. 42ebebc3f5
Remove state: latest 2022-11-14 18:04:01 +01:00
Sam A. 79ec0627d4
Naming changes 2022-11-14 17:50:19 +01:00
Sam A. 3b7c096f8e
Simplify config and rename some files 2022-11-14 00:13:24 +01:00
Sam A. 01d9d3c04b
Don't use local config for Docker registry login
It doesn't work when deploying in Vagrant :(
2022-11-13 22:39:14 +01:00
Sam A. 41f09e7b33
Vagrant: Use same Ubuntu version as in production 2022-11-13 22:04:37 +01:00
Sam A. d0904a96a8
Fix SSH port logic again 2022-11-13 22:03:45 +01:00
Sam A. 581c832b36
Some Vagrant fixes
Only install Dell OpenManage if not running in a VM, and fix SSH port
logic.
2022-11-13 21:42:52 +01:00
Sam A. 6a16328b7b
Make Ansible setup testable in Vagrant
Added logic to change the sshd port if not already configured,
configued Vagrantfile to work properly and fixed a couple of deploy
errors.
2022-11-13 20:26:58 +01:00
10 changed files with 75 additions and 33 deletions

13
Vagrantfile vendored
View file

@ -1,25 +1,18 @@
Vagrant.require_version ">= 1.7.0" Vagrant.require_version ">= 1.7.0"
Vagrant.configure(2) do |config| Vagrant.configure(2) do |config|
config.vm.network "forwarded_port", guest: 19022, host: 19022, id: "new_ssh"
config.vm.define "datacoop" do |datacoop| config.vm.define "datacoop" do |datacoop|
datacoop.vm.box = "ubuntu/bionic64" datacoop.vm.box = "ubuntu/focal64"
datacoop.vm.hostname = "datacoop" datacoop.vm.hostname = "datacoop"
datacoop.vm.provider "virtualbox" do |v| datacoop.vm.provider "virtualbox" do |v|
v.memory = 4096 v.memory = 4096
end end
datacoop.vm.network "private_network", ip: "192.168.0.42"
datacoop.vm.provision "ansible" do |ansible| datacoop.vm.provision "ansible" do |ansible|
ansible.verbose = "v"
ansible.compatibility_mode = "2.0" ansible.compatibility_mode = "2.0"
ansible.playbook = "playbook.yml" ansible.playbook = "playbook.yml"
ansible.ask_vault_pass = true ansible.ask_vault_pass = true
ansible.host_vars = { ansible.verbose = "v"
"datacoop" => {"ansible_python_interpreter" => "/usr/bin/python3.6"}
}
ansible.groups = {
"all" => ["datacoop"]
}
end end
end end
end end

View file

@ -1,19 +1,22 @@
--- ---
- hosts: all - hosts: all
gather_facts: False gather_facts: true
become: true become: true
vars: vars:
base_domain: data.coop base_domain: data.coop
letsencrypt_email: admin@data.coop letsencrypt_email: admin@data.coop
ldap_dn: "dc=data,dc=coop" ldap_dn: "dc=data,dc=coop"
vagrant: "{{ ansible_virtualization_role == 'guest' }}"
ssl_certs_enabled: "{{ vagrant == false }}"
services: services:
- nginx-proxy - nginx-proxy
- postfix
- openldap - openldap
- nextcloud - nextcloud
- passit - passit
- gitea - gitea
- postfix
- matrix_riot - matrix_riot
- privatebin - privatebin
- codimd - codimd

View file

@ -28,9 +28,8 @@
args: args:
creates: "{{ docker_registry.volume_folder }}/auth/htpasswd" creates: "{{ docker_registry.volume_folder }}/auth/htpasswd"
- name: log in to local registry - name: log in to registry
docker_login: docker_login:
registry: "{{ docker_registry.domain }}" registry: "{{ docker_registry.domain }}"
username: "docker" username: "docker"
password: "{{ docker_password }}" password: "{{ docker_password }}"
config_path: "{{ docker_registry.volume_folder }}/auth/config.json"

View file

@ -28,7 +28,7 @@
dest: "{{ mailu.volume_folder }}/certs/cert.pem" dest: "{{ mailu.volume_folder }}/certs/cert.pem"
state: hard state: hard
force: yes force: yes
when: ssl_certs_enabled
- name: hard link to Let's Encrypt TLS key - name: hard link to Let's Encrypt TLS key
file: file:
@ -36,6 +36,7 @@
dest: "{{ mailu.volume_folder }}/certs/key.pem" dest: "{{ mailu.volume_folder }}/certs/key.pem"
state: hard state: hard
force: yes force: yes
when: ssl_certs_enabled
- name: run mail server containers - name: run mail server containers
docker_compose: docker_compose:

View file

@ -44,4 +44,5 @@
- /var/run/docker.sock:/var/run/docker.sock:ro - /var/run/docker.sock:/var/run/docker.sock:ro
env: env:
NGINX_PROXY_CONTAINER: nginx-proxy NGINX_PROXY_CONTAINER: nginx-proxy
when: ssl_certs_enabled

View file

@ -0,0 +1,5 @@
---
- name: Restart sshd
service:
name: sshd
state: restarted

View file

@ -9,7 +9,11 @@
- apparmor - apparmor
- haveged - haveged
- mosh - mosh
- srvadmin-all # Dell OpenManage
- name: Install Dell OpenManage
apt:
name: srvadmin-all
when: ansible_virtualization_role != "guest"
- name: Install necessary packages via pip - name: Install necessary packages via pip
pip: pip:

View file

@ -1,15 +1,15 @@
--- ---
- name: import dell apt signing key - name: Import dell apt signing key
apt_key: apt_key:
id: "1285491434D8786F" id: "1285491434D8786F"
keyserver: "keyserver.ubuntu.com" keyserver: "keyserver.ubuntu.com"
- name: "configure dell apt repo" - name: Configure dell apt repo
apt_repository: apt_repository:
repo: "deb https://linux.dell.com/repo/community/openmanage/10101/focal focal main" repo: "deb https://linux.dell.com/repo/community/openmanage/10101/focal focal main"
state: "present" state: present
- name: "restrict dell apt repo" - name: Restrict dell apt repo"
copy: copy:
dest: "/etc/apt/preferences.d/dell" dest: "/etc/apt/preferences.d/dell"
content: | content: |
@ -17,7 +17,3 @@
Package: * Package: *
Pin: origin "linux.dell.com" Pin: origin "linux.dell.com"
Pin-Priority: 400 Pin-Priority: 400
- name: update apt cache
apt:
update_cache: yes

View file

@ -1,10 +1,12 @@
--- ---
- import_tasks: custom-apt-repos.yml - import_tasks: ssh-port.yml
tags: [setup-custom-apt] tags: [change-ssh-port]
- import_tasks: dell-apt-repo.yml
tags: [setup-dell-apt-repo]
when: vagrant == false
- import_tasks: upgrade.yml - import_tasks: upgrade.yml
tags: [do-full-system-upgrade] tags: [do-full-system-upgrade]
- import_tasks: base.yml - import_tasks: base.yml
tags: [install-base-packages] tags: [install-base-packages]
- import_tasks: users.yml - import_tasks: users.yml
tags: [setup-users] tags: [setup-users]

View file

@ -0,0 +1,38 @@
---
- name: Check if SSH port is already configured
wait_for:
port: 19022
host: "{{ ansible_host }}"
search_regex: "OpenSSH"
connect_timeout: 5
timeout: 10
become: false
delegate_to: localhost
ignore_errors: true
register: ssh_configured
# If we're running in Vagrant, ansible_port is 2222
- name: Change Ansible port to 22 if needed
set_fact:
ansible_port: 22
when: ssh_configured is defined and
ssh_configured.state is undefined and
ansible_port != 2222
- name: Change SSH port on host
lineinfile:
dest: "/etc/ssh/sshd_config"
regexp: "^#?Port"
line: "Port 19022"
register: ssh_changed
notify: "Restart sshd"
when: ssh_configured is defined and
ssh_configured.state is undefined
- name: Ensure sshd is reloaded if needed
meta: flush_handlers
- name: Change Ansible port to 19022
set_fact:
ansible_port: 19022
when: ssh_changed is defined