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 run the install script on the c2d-devtop node in the development environment. 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.

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://gitlab.com/c2platform/c2/ansible-inventory/-/raw/master/scripts/install-dev-environment.sh?ref_type=heads | 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:

sudo lxc delete c2d-rproxy1 --force

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) |
+--------+------------+---------------------------------+--------------+------------------------------+-----------------------------+

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, reboot the machine, or run the following commands:

newgrp lxd
newgrp vboxusers

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).