#unused - name: BASE_QERC_USERFILE set_fact: # Obviously you may also need this same info on the box REMOTE. BASE_QERC_USERFILE: "{{BOX_USER_HOME}}/QeRcUser.yaml" # If the local RUN_QERC_USERFILE is defined and exists and the BASE_QERC_USERFILE is defined, # the local file will be copied to the REMOTE box when: BASE_QERC_USERFILE|default('') == '' - name: "REMOTE BASE_QERC_USERFILE" stat: path: "{{ BASE_QERC_USERFILE }}" register: base_qerc_fact check_mode: false - block: - debug: msg: "INFO: creating ~/QeRcUser.yaml" - name: "Copy the RUN_QERC_USERFILE to REMOTE BASE_QERC_USERFILE" copy: src: "{{ RUN_QERC_USERFILE }}" dest: "{{ BASE_QERC_USERFILE }}" mode: 0600 owner: "{{LOOP_USER}}" when: run_qerc_fact.stat.exists - name: "Create a default REMOTE BASE_QERC_USERFILE" copy: dest: "{{ BASE_QERC_USERFILE }}" mode: 0600 owner: "{{LOOP_USER}}" content: | # -*-mode: yaml; indent-tabs-mode: nil; tab-width: 2; coding: utf-8-unix -*- # The QeRcUser.yaml file is expected to be found in your $HOME directory. # On Windows, you may need to make sure that $HOME is set in the environment, # it does not have to be the same as $USERPROFILE, but usually is. # YAML files must be tab free, and ${/} CANNOT be used - it's YAML not robot. # *** Variables *** MY_CORP_USER: "jdoe" MY_CORP_EMAIL: "jdoe@example.com" MY_CORP_PASS: "MySecret" MY_CORP_DOMAIN: "CORP" # CORP_NTLM_PROXY: "http://example.net:3128" when: not run_qerc_fact.stat.exists when: not base_qerc_fact.stat.exists - block: - debug: msg: "including ~/QeRcUser.yaml" - name: "make a tempfile for ~/QeRcUser.yaml" tempfile: state: file delegate_to: localhost register: qerc_user_yml_file - name: "slurp REMOTE ~/QeRcUser.yaml" slurp: src: "{{ BASE_QERC_USERFILE }}" register: qerc_user_yml - name: "copy slurped ~/QeRcUser.yaml to tempfile" copy: dest: "{{ qerc_user_yml_file.path}}" content: "{{ qerc_user_yml['content']|b64decode }}" delegate_to: localhost - name: "include copied ~/QeRcUser.yaml" include_vars: "{{qerc_user_yml_file.path}}" rescue: - debug: msg: "WARN: error including ~/QeRcUser.yaml"