Vagrant-based testing environment #111

Merged
valberg merged 15 commits from vagrant into main 2022-11-25 13:07:10 +00:00
6 changed files with 59 additions and 10 deletions
Showing only changes of commit b56690a33e - Show all commits

3
Vagrantfile vendored
View file

@ -1,14 +1,13 @@
Vagrant.require_version ">= 1.7.0"
Vagrant.configure(2) do |config|
config.vm.network "forwarded_port", guest: 19022, host: 19022, id: "new_ssh"
config.vm.define "datacoop" do |datacoop|
datacoop.vm.box = "ubuntu/bionic64"
datacoop.vm.hostname = "datacoop"
datacoop.vm.provider "virtualbox" do |v|
v.memory = 4096
end
datacoop.vm.network "private_network", ip: "192.168.0.42"
datacoop.vm.provision "ansible" do |ansible|
ansible.verbose = "v"
ansible.compatibility_mode = "2.0"

View file

@ -9,11 +9,11 @@
services:
- nginx-proxy
- postfix
- openldap
- nextcloud
- passit
- gitea
- postfix
- matrix_riot
- privatebin
- codimd

View file

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

View file

@ -4,17 +4,19 @@
name: "{{ packages }}"
vars:
packages:
- aptitude
- python3-pip
- apparmor
- haveged
- mosh
- srvadmin-all # Dell OpenManage
- aptitude
- python3-pip
- apparmor
- haveged
- mosh
- srvadmin-all # Dell OpenManage
- name: Install necessary packages via pip
pip:
name: "{{ packages }}"
state: latest
vars:
packages:
- pip # upgrade needed for docker-compose to install
- docker
- docker-compose

View file

@ -1,4 +1,6 @@
---
- import_tasks: ssh.yml
tags: [change-ssh-port]
- import_tasks: custom-apt-repos.yml
tags: [setup-custom-apt]
- import_tasks: upgrade.yml
@ -7,4 +9,3 @@
tags: [install-base-packages]
- import_tasks: users.yml
tags: [setup-users]

View file

@ -0,0 +1,42 @@
---
- name: Check if SSH port is already configured
wait_for:
port: 19022
state: started
host: "{{ inventory_hostname }}"
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 or
(ssh_configured.state is defined and
ssh_configured.state != "started")) and
ansible_port != 2222
- name: Change SSH port
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 or
(ssh_configured.state is defined and
ssh_configured.state != "started"))
- name: Ensure sshd is reloaded if needed
meta: flush_handlers
- name: Change ansible_port 19022
set_fact:
ansible_port: 19022
when: ssh_changed is defined