diff --git a/rstudio/rstudio.yml b/rstudio/rstudio.yml index 0f08e86..bccfc9f 100644 --- a/rstudio/rstudio.yml +++ b/rstudio/rstudio.yml @@ -1,68 +1,88 @@ --- -- name: PRE_TASK Update apt cache - become: true - ansible.builtin.apt: - upgrade: true - update_cache: true - autoremove: true - autoclean: true - - -- name: Pip - ansible.builtin.apt: - name: python3-pip - state: latest - - name: Setup password for default user become: true ansible.builtin.user: - name: "{{ rstudio_vars.default_user }}" - password: "{{ rstudio_vars.default_password | password_hash('sha512') }}" - update_password: always - password_lock: false + name: "{{ rstudio_vars.default_user }}" + password: "{{ rstudio_vars.default_password | password_hash('sha512') }}" + update_password: always + password_lock: false + +- name: Update package index + become: true + apt: + update_cache: true + when: not rstudio_vars.create_only_backend +- name: Install apt-file + become: true + apt: + name: apt-file + state: present + when: not rstudio_vars.create_only_backend - name: Install R role include_role: - name: oefenweb.latest_r + name: oefenweb.latest_r + vars: + r_packages: + - name: remotes + - name: cran4linux/rspm + type: github when: not rstudio_vars.create_only_backend - name: Install rstudio-server role include_role: - name: oefenweb.rstudio_server + name: oefenweb.rstudio_server vars: - rstudio_install: [r-base] - rstudio_server_version: "{{ rstudio_vars.RSTUDIO_VERSION | replace('v', '') | replace('+', '-') }}" + rstudio_install: [r-base] + rstudio_server_version: "{{ rstudio_vars.RSTUDIO_VERSION | replace('v', '') | replace('+', '-') }}" when: not rstudio_vars.create_only_backend + +- name: Ensure .Rprofile file exists + become: true + file: + path: /home/{{ rstudio_vars.default_user }}/.Rprofile + state: touch + when: not rstudio_vars.create_only_backend +- name: Configure R profile + become: true + become_user: ubuntu + blockinfile: + path: /home/{{ rstudio_vars.default_user }}/.Rprofile + marker: "# {mark} ANSIBLE MANAGED BLOCK" + block: | + suppressMessages(rspm::enable()) + when: not rstudio_vars.create_only_backend + - name: Install essential system packages ansible.builtin.apt: - name: - - build-essential - - libcurl4-openssl-dev - - libssl-dev - - zlib1g-dev - - libpng-dev - - libjpeg-dev - - libtiff-dev - - libfreetype6-dev - - libfontconfig1-dev - - libmysqlclient-dev - - libsqlite3-dev - - libpq-dev - - libfribidi-dev - - libharfbuzz-dev - - libxml2-dev - - cmake - state: present + name: + - build-essential + - libcurl4-openssl-dev + - libssl-dev + - zlib1g-dev + - libpng-dev + - libjpeg-dev + - libtiff-dev + - libfreetype6-dev + - libfontconfig1-dev + - libmysqlclient-dev + - libsqlite3-dev + - libpq-dev + - libfribidi-dev + - libharfbuzz-dev + - libxml2-dev + - cmake + state: present become: true - name: Copy session file if also installing rstudio ansible.builtin.copy: - content: session-timeout-minutes=180 - dest: "{{ rstudio_vars.RSESSION_FILE_PATH }}" - mode: "0644" - owner: root - group: root + content: session-timeout-minutes=180 + dest: "{{ rstudio_vars.RSESSION_FILE_PATH }}" + mode: "0644" + owner: root + group: root when: not rstudio_vars.create_only_backend - name: Flush rstudio handlers