Commit 95f39835 authored by onknows's avatar onknows
Browse files

howto c2 devtop install script

C2-1591
parent 6468e6b9
Loading
Loading
Loading
Loading
+63 −43
Changes for content/en/docs/howto/c2/devtop/install-script/_index.md: 63 added lines, 43 removed lines.
Original line number Diff line number Diff line
@@ -22,19 +22,22 @@ Projects:

## Overview

This how-to shows how to run the install script on the `c2d-devtop` node
in the [development environment](g). The script executes the desktop role
in local play mode. It creates a personal development environment for the
vagrant user by cloning Git repositories, setting up a Visual Studio Code
workspace, adding an aliases file, and configuring the standard C2
Platform development environment.

The script is a fully non-interactive bootstrap for any user on Ubuntu
24.04. It detects or creates an SSH key, clones the inventory project,
prepares a Python virtual environment, installs requirements, roles and
collections, and then runs the local playbook `plays/dev/desktop_local.yml`.
That playbook applies the desktop role to converge the personal
development environment.
This how-to shows how to use one [development environment](g) to create
and test another. Starting from an existing C2 Platform
[development environment](g) on a high-end development laptop, you sign
in to `c2d-devtop` and run the install script there. The script executes
the desktop role in local play mode to bootstrap a second personal
[development environment](g) for the current local user. This lets you
develop and test the automation that creates the development environment
itself without breaking the host environment.

The bootstrap is fully non-interactive on Ubuntu 24.04. It detects or
creates an SSH key, clones the inventory project, prepares a Python
virtual environment, installs requirements, roles, and collections, and
then runs the local playbook `plays/dev/desktop_local.yml`. That
playbook applies the desktop role to converge the personal development
environment on `c2d-devtop`. You then use that environment to provision
`c2d-rproxy1` and test the install script and desktop role end to end.

## Prerequisites

@@ -124,26 +127,9 @@ The container `c2d-rproxy1` already exists because it was created by the
An Ansible development environment that uses local virtualization
(VirtualBox or LXD) is single-user. Only one user can use the environment
at a time. The install script does not remove nodes created by other
users. You can delete the container manually:
users. You can delete the container manually[^lxd-delete] TODO moeten we langrijk punt toevoegen dat dit dat dit een situatie is die beide zijn bewust niet worden ondersteund door het script en de desktop omdat als het gaat om user die sorry om de development omgeving die single user is en vanwege fit valisatie die maar door één gebruik technisch tegelijkertijd gebruikt kan worden en dat er een switch moeten plaatsvinden en dat is iets en dan hebben we het over een sheet die gemanaged wordt zoals het zit platform dat doet of door de organisatie zelf gemanaged worden waar de desktop all via een normal play wordt uitgevoerd en dan en niet als een local play en dan zal er een desktop switch uitgevoerd. Maar hier moeten we ook vermelden dat we dan een desktop switch gaan uitvoeren door de normal play te draaien. En dat doen we verderop in dit document.

```bash
sudo lxc delete c2d-rproxy1 --force
```

The desktop role does update the LXD trust. You can inspect it with:

```bash
lxc config trust ls
```

```shell{style=swapoff}
(c2) local-play-test-user@c2d-devtop:~/git/gitlab/c2/ansible-c2d$ lxc config trust ls
+--------+------------+---------------------------------+--------------+------------------------------+-----------------------------+
|  TYPE  |    NAME    |           COMMON NAME           | FINGERPRINT  |          ISSUE DATE          |         EXPIRY DATE         |
+--------+------------+---------------------------------+--------------+------------------------------+-----------------------------+
| client | client.crt | local-play-test-user@c2d-devtop | fcbe00bfc1b1 | Aug 10, 2026 at 8:09am (UTC) | Aug 7, 2036 at 8:09am (UTC) |
+--------+------------+---------------------------------+--------------+------------------------------+-----------------------------+
```
TODO nog opmerking toevoegen dat de desktoprol wel altijd de LXD trust aanpast en dan verwijzen naar de voetnoot[^desktop-trust].

The new user is also added to the `vboxusers` and `lxd` groups, but these
are not yet active:
@@ -155,23 +141,16 @@ local-play-test-user@c2d-devtop:~/git/gitlab/c2/ansible-c2d$ groups
local-play-test-user sudo
```

Log out and log back in, reboot the machine, or run the following commands:

```bash
newgrp lxd
```

```bash
newgrp vboxusers
```

Afterwards the user belongs to both groups:
Log out and log back in or use `newgrp` commands[^newgrp]. Afterwards the user belongs to both groups:

```shell{style=swapoff}
local-play-test-user@c2d-devtop:~$ groups
local-play-test-user sudo lxd vboxusers
```




With the correct LXD trust, group membership, and no existing node you can
now run the provisioning command successfully:

@@ -189,3 +168,44 @@ created by the previous user).

TODO
(c2) vagrant@c2d-devtop:~/git/gitlab/c2/ansible-c2d$ ansible-playbook plays/dev/desktop_local.yml -i hosts.ini | tee provision.log

TODO
Misschien ook na install script als test user dan ook weer vagrant provision c2d-devtop vanaf host zie C2-1626

[^lxc-delete]: You can delete the LXD container that Vagrant created (owned by
    `vagrant`) by using the command:

    ```bash
    sudo lxc delete c2d-rproxy1 --force
    ```

[^desktop-trust]: The desktop role does update the LXD trust. You can inspect it
    with:

    ```bash
    lxc config trust ls
    ```

    ```shell{style=swapoff}
    (c2) local-play-test-user@c2d-devtop:~/git/gitlab/c2/ansible-c2d$ lxc config trust ls
    +--------+------------+---------------------------------+--------------+------------------------------+-----------------------------+
    |  TYPE  |    NAME    |           COMMON NAME           | FINGERPRINT  |          ISSUE DATE          |         EXPIRY DATE         |
    +--------+------------+---------------------------------+--------------+------------------------------+-----------------------------+
    | client | client.crt | local-play-test-user@c2d-devtop | fcbe00bfc1b1 | Aug 10, 2026 at 8:09am (UTC) | Aug 7, 2036 at 8:09am (UTC) |
    +--------+------------+---------------------------------+--------------+------------------------------+-----------------------------+
    ```

[^newgrp]: TODO om de juiste rechten te krijgen zonder logout, login, kan de
    user de nieuwe GRP commando gebruiken. Dus in deze footnote laten we dan
    zien dat de twee commando's zijn. En we leggen heel kort even uit wat het
    commando doet. Volgens mij is dat dat hij een soort van nieuwe sessie open.
    Dus je kunt die commando's ook niet in één keer doen. Je moet ze na elkaar
    doen.

    ```bash
    newgrp lxd
    ```

    ```bash
    newgrp vboxusers
    ```