Coder Social home page Coder Social logo

ansible-role-code-server's Introduction

ansible-role-code-server

Ansible Role Build Status Keep a Changelog

This role installs and configures the latest or specified version of code-server, supporting v4, v3, v2 and v1.

# Install the latest stable version of the role
ansible-galaxy install -f pallxk.code_server

# Install the latest development version of the role
ansible-galaxy install -f pallxk.code_server,master

To actually install code-server, refer to the section Example Playbook.

Note: The version of the role is irrelevant to the version of code-server you can install. Actually, it installs the latest version of code-server by default. And you can also use a lower-versioned role to install a higher-versioned code-server.
When there are changes to the role, the role version will get updated to the latest version number of code-server.
If you're having problems installing any version of code-server, please report the issue.

Requirements

None.

Role Variables

Variable Default Comment
code_server_ver (undefined) code-server release name on GitHub.
Defaults to the latest version (including pre-release).
code_server_install_prefix /usr/local Installation prefix for code-server.
code_server_data_dir {{ ansible_user_dir }}/.local/share/code-server Defaults to .local/share/code-server in the home directory of the remote user.
code_server_work_dir (undefined) Working directory.
Defaults to welcome screen if not set in v3 and v2.
Defaults to the home directory of the remote user in v1.
code_server_auth password Authentication with password or none.
Available for code-server v3 and v2.
code_server_password (undefined) Leave undefined to use auto-generated password.
Check it with journalctl -u code-server
code_server_user {{ ansible_user_id }} The user to run code-server.
Defaults to the user used in ansible ssh connection.
code_server_host 0.0.0.0
code_server_port 8080
code_server_env {} Additional environment variables to set for code-server.
code_server_tls_cert (undefined) Leave undefined to use self-signed certificate.
code_server_tls_cert_remote no Change to yes if you're using a certificate that's already in your server (e.g.: if you use Let's Encrypt)
code_server_tls_key (undefined) Leave undefined to use self-signed certificate.
code_server_tls_key_remote no Change to yes if you're using a key that's already in your server (e.g.: if you use Let's Encrypt)

Dependencies

None.

Example Playbook

#!/usr/bin/env ansible-playbook
---
- hosts: localhost
  gather_facts: yes
  roles:
    - name: pallxk.code_server
      code_server_password: SuperSecret
      code_server_user: "{{ ansible_user_id }}"
      code_server_host: 0.0.0.0
      code_server_port: 8443
      code_server_env:
        # code-server v4
        # v4 defaults to use open-vsx.org,
        # if you want to use the legacy Coder extensions marketplace, add the following:
        EXTENSIONS_GALLERY: >
          {
            "serviceUrl": "https://extensions.coder.com/api"
          }
        # code-server v3
        # v3 defaults to use Coder extensions marketplace,
        # if you want to use open-vsx.org, add the following:
        SERVICE_URL: https://open-vsx.org/vscode/gallery
        ITEM_URL: https://open-vsx.org/vscode/item
      code_server_tls_cert: /etc/letsencrypt/live/example.com/fullchain.pem
      code_server_tls_key: /etc/letsencrypt/live/example.com/privkey.pem

License

The MIT License (MIT)

Author Information

pallxk testcab

ansible-role-code-server's People

Contributors

ikea-shark-official avatar lukeshortcloud avatar pallxk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ansible-role-code-server's Issues

Fails to install ("code-server: command not found")

I tried to use this to install code-server on a Fedora 30 computer and it failed with the following error:

[colby@laptop ansible]$ ansible-playbook services/code-server.yml 

PLAY [tv] ************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************
ok: [192.168.1.100]

TASK [include_role : pallxk.code_server] *****************************************************************************

TASK [pallxk.code_server : Include RedHat specific tasks] ************************************************************
included: /home/colby/.ansible/roles/pallxk.code_server/tasks/RedHat.yml for 192.168.1.100

TASK [pallxk.code_server : Include RedHat specific variables] ********************************************************
ok: [192.168.1.100]

TASK [pallxk.code_server : Create /usr/local/lib/systemd/system] *****************************************************
changed: [192.168.1.100]

TASK [pallxk.code_server : Check systemd version] ********************************************************************
ok: [192.168.1.100]

TASK [pallxk.code_server : Check code-server v1 version] *************************************************************
skipping: [192.168.1.100]

TASK [pallxk.code_server : Check code-server v2 version] *************************************************************
fatal: [192.168.1.100]: FAILED! => {"changed": false, "cmd": "set -o pipefail; code-server --version | head -1 | cut -d' ' -f3", "delta": "0:00:00.003311", "end": "2019-09-02 13:49:34.406433", "msg": "non-zero return code", "rc": 127, "start": "2019-09-02 13:49:34.403122", "stderr": "/bin/sh: code-server: command not found", "stderr_lines": ["/bin/sh: code-server: command not found"], "stdout": "", "stdout_lines": []}

PLAY RECAP ***********************************************************************************************************
192.168.1.100              : ok=5    changed=1    unreachable=0    failed=1    skipped=1    rescued=0    ignored=0   

it seems that this is unable to install on systems without code-server already installed because it errors out after being unable to find the executable.

Service fails to start with "Exec format error"

The target host is a Raspberry Pi 4.

To reproduce run

$ /usr/local/bin/code-server --auth none --host 0.0.0.0 --port 8443
/usr/local/bin/code-server: 36: exec: /opt/code-server/lib/node: Exec format error

Personal note, I suspect that this is related to the architecture of the machine (ARM), and some dependency that is being fetched compiled to x86?

Fails to enable systemd unit on install [Fedora 30]

Upon initial install, the systemd unit isn't properly detected.


TASK [pallxk.code_server : Enable code-server service] ***************************************************************
fatal: [192.168.1.100]: FAILED! => {"changed": false, "msg": "Could not find the requested service code-server: host"}

I initially thought this was something wrong with the script, but I sshed into the server and tried daemon-reload+starting the service manually, and it didn't work either. Rebooting the system fixed the problem.

My best guess is that there's a bug in systemd that prevents it from seeing unit files in /usr/local/... unless the folder exists at boot. I'll do some testing and report it upstream when I find the time.

This issue is mostly just to remind myself to do something.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.