UNPKG

@installdoc/ansible-gas-station

Version:

An Ansible playbook that provisions your network with software from GitHub Awesome lists, developed with disaster recovery in mind ⛽🔥🤤

89 lines (77 loc) 3.23 kB
--- - name: "Ensure {{ app_name }} is installed" become_method: runas become_user: "{{ ansible_user | default(lookup('env', 'USER')) }}" block: - name: Ensure Megabyte Labs configuration directory exists ansible.windows.win_file: path: "{{ item }}" state: directory loop: - '%USERPROFILE%\.config' - '%USERPROFILE%\.config\megabytelabs' - name: "Check if {{ app_name }} has configuration stored in '%USERPROFILE%/.config/megabytelabs/nvm'" ansible.windows.win_stat: path: '%USERPROFILE%\.config\megabytelabs\nvm' register: nvm_config - name: "Detect previously installed {{ app_name }} version" ansible.windows.win_shell: type nvm args: chdir: '%USERPROFILE%\.config\megabytelabs' changed_when: false register: current_nvm_version when: nvm_config.stat.exists - name: "Detect the latest {{ app_name }} version" ansible.windows.win_uri: url: https://api.github.com/repos/coreybutler/nvm-windows/releases/latest return_content: true register: nvm_latest_release_tag - name: "Determine whether or not the latest version of {{ app_name }} is already installed" set_fact: install_nvm: "{{ (current_nvm_version.skipped | default(false)) or \ ((not current_nvm_version.skipped | default(false)) and (current_nvm_version.stdout | trim != nvm_latest_release_tag.json.tag_name)) }}" - name: "Ensure {{ app_name }} archive is downloaded" ansible.windows.win_get_url: url: "{{ 'https://github.com/coreybutler/nvm-windows/releases/download/' + nvm_latest_release_tag.json.tag_name + '/nvm-noinstall.zip' }}" dest: '%TEMP%\nvm-noinstall.zip' force: true when: install_nvm - name: "Ensure {{ app_name }} is installed" community.windows.win_unzip: src: '%TEMP%\nvm-noinstall.zip' dest: '%PROGRAMDATA%\nvm\' delete_archive: true when: install_nvm - name: Create settings.txt ansible.windows.win_copy: dest: '%PROGRAMDATA%\nvm\settings.txt' content: | root: C:\ProgramData\nvm path: C:\ProgramData\nodejs arch: 64 proxy: none when: install_nvm - name: Ensure envrionment variables are configured ansible.windows.win_environment: name: "{{ item.name }}" value: "{{ item.path }}" level: machine state: present with_items: - name: NVM_HOME path: 'C:\ProgramData\nvm' - name: NVM_SYMLINK path: 'C:\ProgramData\nvm\nodejs' - name: "Ensure {{ app_name }} installation is added to PATH" ansible.windows.win_path: elements: "%NVM_HOME%;%NVM_SYMLINK%" state: present - name: "Save meta information about the version of {{ app_name }} that was installed" ansible.windows.win_copy: dest: '%USERPROFILE%\.config\megabytelabs\nvm' content: | {{ nvm_latest_release_tag.json.tag_name }} when: install_nvm - name: Ensure NPM packages are installed ansible.windows.win_shell: npm install -g {{ item.name }}@latest loop: "{{ nodejs_npm_global_packages | default([]) }}"