- name: Create code-server data dir
  file:
    path: "{{ code_server_data_dir }}"
    state: directory

- name: Copy code-server env file
  template:
    src: env
    dest: "{{ code_server_data_dir }}"
    mode: 0600
  notify: Restart code-server
  when: code_server_password is defined or
        code_server_env|length > 0

- block:
  - import_tasks: copy-certs.yml
  rescue:
  - import_tasks: copy-certs.yml
    become: yes
