Run the Install Script

Learn how to run the one-command install script on the c2d-devtop node. The script executes the desktop role in local play mode to set up a personal development environment for a local user.

Projects:  c2platform/c2/ansible-inventory ,  c2platform.dev.desktop

Overview

This how-to shows how to use one development environment to create and test another. Starting from an existing C2 Platform development environment 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 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

Install script

Use Remmina to open an RDP session to the node as the vagrant user. Run the install script as described in the development environment setup guide:

wget -qO- https://c2platform.org/install.sh | bash

Open a new terminal so the updated terminal configuration becomes active. Activate the Python virtual environment with the c2d alias and then provision the reverse proxy node c2d-rproxy1.

c2d
vagrant up c2d-rproxy1

Test with a new account

Test the local play with a new user account. As the vagrant user, create the account with the commands below.

export TEST_USER=local-play-test-user
sudo userdel -r $TEST_USER
sudo useradd -G sudo $TEST_USER -m -s /bin/bash -c "Test account for local play"
echo "$TEST_USER:secret" | sudo chpasswd

Log in again as local-play-test-user with password secret and run the install script again. Provisioning c2d-rproxy1 fails with the following error:

409 - Error: Instance “c2d-rproxy1” already exists

Show me
(c2) local-play-test-user@c2d-devtop:~/git/gitlab/c2/ansible-c2d$ vagrant up c2d-rproxy1
Bringing machine 'c2d-rproxy1' up with 'lxd' provider...
==> c2d-rproxy1: Machine has not been created yet, starting...
==> c2d-rproxy1: Box 'c2platform/ubuntu-jammy' could not be found. Attempting to find and install...
    c2d-rproxy1: Box Provider: lxc
    c2d-rproxy1: Box Version: 0.1.0
==> c2d-rproxy1: Loading metadata for box 'c2platform/ubuntu-jammy'
    c2d-rproxy1: URL: https://vagrantcloud.com/api/v2/vagrant/c2platform/ubuntu-jammy
==> c2d-rproxy1: Adding box 'c2platform/ubuntu-jammy' (v0.1.0) for provider: lxc
    c2d-rproxy1: Downloading: https://vagrantcloud.com/c2platform/boxes/ubuntu-jammy/versions/0.1.0/providers/lxc/unknown/vagrant.box
    c2d-rproxy1: Calculating and comparing box checksum...
==> c2d-rproxy1: Successfully added box 'c2platform/ubuntu-jammy' (v0.1.0) for 'lxc'!
==> c2d-rproxy1: Converting LXC image to LXD format...
/home/local-play-test-user/.vagrant.d/gems/3.1.4/gems/vagrant-lxd-0.7.1/lib/vagrant-lxd/driver.rb:299:in `rescue in create': undefined method `reason' for #<Hyperkit::Conflict: POST https://127.0.0.1:8443/1.0/instances?project=default: 409 - Error: Instance "c2d-rproxy1" already exists> (NoMethodError)

      if e.reason =~ /Container '([^']+)' already exists/

The container c2d-rproxy1 already exists because it was created by the vagrant user. You can confirm this with sudo lxc ls:

(c2) local-play-test-user@c2d-devtop:~/git/gitlab/c2/ansible-c2d$ sudo lxc ls
+-------------+---------+---------------------+------+-----------+-----------+
|    NAME     |  STATE  |        IPV4         | IPV6 |   TYPE    | SNAPSHOTS |
+-------------+---------+---------------------+------+-----------+-----------+
| c2d-rproxy1 | RUNNING | 10.181.4.149 (eth0) |      | CONTAINER | 0         |
|             |         | 1.1.4.205 (eth1)    |      |           |           |
+-------------+---------+---------------------+------+-----------+-----------+

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[^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.

TODO nog opmerking toevoegen dat de desktoprol wel altijd de LXD trust aanpast en dan verwijzen naar de voetnoot1.

The new user is also added to the vboxusers and lxd groups, but these are not yet active:

local-play-test-user@c2d-devtop:~/git/gitlab/c2/ansible-c2d$ cat /etc/group | grep lxd
lxd:x:110:vagrant,local-play-test-user
local-play-test-user@c2d-devtop:~/git/gitlab/c2/ansible-c2d$ groups
local-play-test-user sudo

Log out and log back in or use newgrp commands2. Afterwards the user belongs to both groups:

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:

vagrant up c2d-rproxy1

Conclusion

The install script runs the desktop role in local play mode to set up a personal development environment. The Ansible development environment is single-user when local virtualization is used. The desktop role supports switching users by updating the LXC trust (except for removing nodes 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


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

    lxc config trust ls
    
    (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) |
    +--------+------------+---------------------------------+--------------+------------------------------+-----------------------------+
    
     ↩︎
  2. 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.

    newgrp lxd
    
    newgrp vboxusers
    
     ↩︎


Last modified September 8, 2026: howto c2 devtop install script C2-1591 (95f3983)