Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isolate FTS #118

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pending/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.vagrant.d/boxes
key: ${{ runner.os }}-vagrant-${{ hashFiles('Vagrantfile') }}
key: "${{ runner.os }}-vagrant-${{ hashFiles('Vagrantfile') }}"
restore-keys: |
${{ runner.os }}-vagrant-
"${{ runner.os }}-vagrant-"

- name: Run vagrant up
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pending/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: "${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}"
restore-keys: |
${{ runner.os }}-pip-
"${{ runner.os }}-pip-"

- name: Install test dependencies
run: pip3 install yamllint
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pending/molecule_all_on_one.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: "${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}"
restore-keys: |
${{ runner.os }}-pip-
"${{ runner.os }}-pip-"

- name: Install test dependencies
run: pip3 install ansible molecule[docker] docker
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pending/molecule_fts_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ name: FTS CORE (DOCKER)
- '**.md'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -69,9 +69,9 @@ jobs:
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: "${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}"
restore-keys: |
${{ runner.os }}-pip-
"${{ runner.os }}-pip-"

- name: Install test dependencies
run: pip3 install ansible molecule[docker] docker
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pending/molecule_multiple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: "${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}"
restore-keys: |
${{ runner.os }}-pip-
"${{ runner.os }}-pip-"

- name: Install test dependencies
run: pip3 install ansible molecule[docker] docker
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pending/molecule_mumble.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ jobs:
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: "${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}"
restore-keys: |
${{ runner.os }}-pip-
"${{ runner.os }}-pip-"

- name: Install test dependencies
run: pip3 install ansible molecule[docker] docker
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pending/molecule_noderedserver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ jobs:
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: "${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}"
restore-keys: |
${{ runner.os }}-pip-
"${{ runner.os }}-pip-"

- name: Install test dependencies
run: pip3 install ansible molecule[docker] docker
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pending/molecule_videoserver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ jobs:
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
key: "${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}"
restore-keys: |
${{ runner.os }}-pip-
"${{ runner.os }}-pip-"

- name: Install test dependencies
run: pip3 install ansible molecule[docker] docker
Expand Down
21 changes: 21 additions & 0 deletions docs/fts-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
description: "a VM for testing FTS"
version: "24.4.0"

# see https://doc.qt.io/qt-5/qsysinfo.html#currentCpuArchitecture
runs-on:
- x86_64

instances:
fts-test:
image: 22.04
limits:
min-cpu: 2
min-mem: 4G
min-disk: 10G
# timeout: <int> # maximum time for the instance to launch, and separately for cloud-init to complete
# cloud-init:
# vendor-data: | # cloud-init vendor data
# <string>
# a health-check shell script ran by integration tests
health-check: |
lsb_release -a
4 changes: 2 additions & 2 deletions docs/ubuntu_rasppi_test.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ to get the `easy_install.sh` from the same repository and branch as the ZTI.
The official GitHub is `FreeTAKTeam`,
if you are working in a fork you will need to use that.
```bash
export MY_IP=$(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
export MY_IPA=$(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
export MY_GITHUB=FreeTAKTeam
````

```bash
wget -qO - https://raw.githubusercontent.com/${MY_GITHUB}/FreeTAKHub-Installation/main/scripts/easy_install.sh | sudo bash -s -- --verbose --repo https://github.com/${MY_GITHUB}/FreeTAKHub-Installation.git --branch main --ip-addr ${MY_IP}
wget -qO - https://raw.githubusercontent.com/${MY_GITHUB}/FreeTAKHub-Installation/main/scripts/easy_install.sh | sudo bash -s -- --verbose --repo https://github.com/${MY_GITHUB}/FreeTAKHub-Installation.git --branch main --ip-addr ${MY_IPA}
```


Expand Down
30 changes: 26 additions & 4 deletions docs/ubuntu_vm_test.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,27 @@ Note: On Windows you will need
to [enable privileged mounts](https://multipass.run/docs/privileged-mounts).
```shell
multipass set local.privileged-mounts=true
````
```

Make a mount point on the virtual machine.
Mount the directory containing the working repository.
```shell
multipass exec fts-test -- mkdir fts-zti
multipass mount $HOME/fts-installer fts-test:/home/ubuntu/fts-zti
````
```

We can verify the mount point on the image.
```shell
multipass info fts-test
```

Make a snapshot.
```shell
multipass stop fts-test
multipass snapshot fts-test
```
This will create a snapshot and provide its name.

### Run the ZTI

Start the prepared virtual machine.
Expand All @@ -70,7 +77,8 @@ You may change the configured IP address later,
but it is easiest to handle it now.
It is likely you will want interface `eth0`.
```bash
export MY_IP=$(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
export MY_IPA=$(ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
echo "My IPA: ${MY_IPA}"
````

Install FTS using the candidate ZTI.
Expand All @@ -81,7 +89,11 @@ Notice that in the following command the `easy_install.sh` is taken from
a working tree, while the branch is from the committed repository.

```bash
cat /home/ubuntu/fts-zti/scripts/easy_install.sh | sudo bash -s -- --verbose --repo file:///home/ubuntu/fts-zti/.git --branch main --ip-addr ${MY_IP}
cat /home/ubuntu/fts-zti/scripts/easy_install.sh | sudo NO_COLOR=TRUE bash -s -- --verbose --repo file:///home/ubuntu/fts-zti/.git --branch main --ip-addr ${MY_IPA}
```
If you want to use Python packages from the https://test.pypi.org repository.
```bash
cat /home/ubuntu/fts-zti/scripts/easy_install.sh | sudo bash -s -- --verbose --repo file:///home/ubuntu/fts-zti/.git --branch main --ip-addr ${MY_IPA} --pypi https://test.pypi.org
```

### Configuration
Expand All @@ -100,8 +112,18 @@ Those instructions will not be duplicated here.

## Resetting the `multipass` VM

### Hard Reset

```shell
multipass stop fts-test
multipass delete fts-test
multipass purge
```

### Soft Reset

The soft reset rolls back to a previous snapshot.
(You did make a snapshot, right?)
```shell
multipass restore fts-test.snapshot1
```
1 change: 1 addition & 0 deletions install_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- name: Cleanup
import_tasks: roles/common/tasks/cleanup.yml


post_tasks:
- name: Reload Node-RED Server flows to ensure Video Server connection
import_tasks: roles/nodered/tasks/reload-flows.yml
Expand Down
1 change: 1 addition & 0 deletions roles/common/files/ansible-fts-user.sudo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
%fts ALL=(ALL) NOPASSWD: ALL
51 changes: 51 additions & 0 deletions roles/common/tasks/configure-Ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---

- name: Make sure we have an 'fts' group
ansible.builtin.group:
name: fts
state: present

- name: Allow 'fts' group to have passwordless sudo
ansible.builtin.copy:
content: "%fts ALL=(ALL) NOPASSWD: ALL"
dest: /etc/sudoers.d/80-ansible-fts-user
validate: 'visudo -cf %s'

- name: Add fts user to the fts group
ansible.builtin.user:
name: fts
groups: fts,sudo
group: fts
append: yes
state: present
create_home: true
generate_ssh_key: true
ssh_key_file: .ssh/id_rsa
system: true

- name: Set up authorized keys for the installing user
ansible.posix.authorized_key:
user: fts
key: "{{ item }}"
state: present
with_file:
- /home/fts/.ssh/id_rsa.pub

- name: Establish fts base folder {{ fts_base_path }}
ansible.builtin.file:
path: "{{ fts_base_path }}"
group: fts
owner: fts
recurse: true
state: directory
mode: u+rw,g+rw,o+r

- name: Establish fts venv of {{ fts_venv }}
ansible.builtin.file:
path: "{{ fts_venv }}"
group: fts
owner: fts
recurse: true
state: directory
mode: u+rw,g+rw,o+r

2 changes: 2 additions & 0 deletions roles/common/tasks/kill.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
- name: Get running processes
become: true
become_user: root
ansible.builtin.shell: "ps -ef | grep -v grep | grep -w {{ process | string }}"
register: running_process_var
failed_when: false
Expand Down
15 changes: 12 additions & 3 deletions roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
---
- name: "Include {{ ansible_distribution }}-specific variables"
include_vars: "{{ ansible_distribution }}.yml"
- name: "Include Common {{ ansible_distribution }}-specific variables"
ansible.builtin.include_vars:
file: "{{ ansible_distribution }}.yml"

- name: Configure Path
ansible.builtin.include_tasks:
file: "configure-{{ ansible_distribution }}.yml"
# ansible.builtin.vars:
# fts_base_path: "{{ fts_base_path }}"
# fts_venv: "{{ fts_venv }}"

- name: Setup
include_tasks: "setup-{{ ansible_distribution }}.yml"
ansible.builtin.include_tasks:
file: "setup-{{ ansible_distribution }}.yml"
4 changes: 4 additions & 0 deletions roles/common/tasks/service.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
- name: Enable service
become: true
become_user: root
service:
name: "{{ service_name }}"
enabled: "{{ service_enabled }}"
Expand All @@ -9,6 +11,8 @@
until: enable_service is success

- name: Set service state
become: true
become_user: root
service:
name: "{{ service_name }}"
state: "{{ service_state }}"
Expand Down
4 changes: 3 additions & 1 deletion roles/common/vars/Ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
---
unit_files_location: /etc/systemd/system
unit_files_location: "/etc/systemd/system"

fts_base_path: "/opt/fts"
6 changes: 5 additions & 1 deletion roles/freetakserver/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
# system information
fts_ipv4: 0.0.0.0

# The URL of the python package repository.
pypi_url: ""

fts_pip_package_name: FreeTAKServer

fts_service_name: fts

# Set initial service state. Recommended values: `started` or `stopped`.
fts_state: started

# Enable service. Recommended values: `true` or `false`
# Enable service. Recommended values: `true` or `false`.
fts_enabled: true

# The relative path to the MainConfig.py file (from the fts_install_path).
cfg_rpath: "core/configuration"
14 changes: 9 additions & 5 deletions roles/freetakserver/tasks/configure-Ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
---

- name: Template FTSConfig.yaml config file
become: true
become_user: fts
template:
src: FTSConfig.yaml.j2
dest: "{{ fts_config_path }}"
owner: root
group: root
mode: 0644
owner: fts
group: fts
mode: 0664

- name: Change FirstStart to False in MainConfig.py
lineinfile:
# path: "{{ fts_install_path }}/controllers/configuration/MainConfig.py"
path: "{{ fts_install_path }}/{{ cfg_rpath }}/MainConfig.py"
regexp: '(\s+)first_start = True'
line: '\1first_start = False'
backrefs: true

- name: Template unit file
become: true
become_user: root
template:
src: fts.service.j2
dest: "{{ unit_files_location }}/{{ fts_service_name }}.service"
owner: root
group: root
mode: 0644
mode: 0664

- name: Kill any currently running processes
include_tasks: ../../common/tasks/kill.yml
Expand Down
2 changes: 1 addition & 1 deletion roles/freetakserver/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

- name: Get public IPv4
uri:
url: http://ifconfig.me/ip
url: https://ifconfig.me/ip
return_content: true
register: ip_response

Expand Down
Loading
Loading