--- - name: Acquiring home of current user when: ansible_facts["system"] == "Linux" ansible.builtin.shell: cmd: "echo ~{{ ansible_user }}" register: ansible_user_home - name: Linking binaries to directories already in PATH environment variable become: true ansible.builtin.file: src: "{{ ansible_user_home.stdout }}/downloads/archives/released/surge/{{ item }}" dest: "/usr/local/bin/{{ item }}" state: link loop: - surge - name: Installing accompanying complementary Surge system service ansible.builtin.command: cmd: surge service install - name: Acquiring API token for remote Surge service control ansible.builtin.command: cmd: surge token register: surge_token - name: Pausing to inquire about how to proceed ansible.builtin.pause: prompt: "Type \"fetch\" to get the Surge API token, or \"show\" to see it for manual copying instead" echo: true register: data_method - name: Choosing to present Surge API token to Control Node when: data_method.user_input == "show" block: - name: Presenting Surge API token to Control Node ansible.builtin.debug: msg: "Make sure to store the following API token for Surge:\n {{ surge_token.stdout }}" - name: Giving opportunity to manually copy Surge API token ansible.builtin.pause: - name: Choosing to provide file on control node containing Surge's API token when: data_method.user_input == "fetch" block: - name: Creating temporary file on managed node that stores Surge API token become: true ansible.builtin.copy: content: "{{ surge_token.stdout }}" dest: /tmp/surge.token owner: "{{ ansible_user }}" group: "{{ ansible_user }}" mode: "644" state: touch register: surge_token - name: Placing Surge API token into file on control node ansible.builtin.fetch: src: "{{ surge_token.dest }}" dest: "/var/tmp/{{ inventory_hostname }}/surge.token" flat: true - name: Informing control node of acquired files ansible.builtin.debug: msg: "The Surge API token file have been duplicated to '/var/tmp/{{ inventory_hostname }}/surge.token' at the control node." - name: Giving control node user time to read the aforementiioned message ansible.builtin.pause: seconds: 30