--- # Install and configure p4prometheus and its rsyslog prerequisite. - name: "Install rsyslog" ansible.builtin.package: name: "rsyslog" state: present - name: "Query Perforce server case handling" become: true become_user: "{{ perforce_user }}" ansible.builtin.shell: cmd: "source /p4/common/bin/p4_vars {{ perforce_id }} && p4 -ztag -F %caseHandling% info" executable: /bin/bash register: p4_case_handling changed_when: false - name: "Download and set permissions on p4prometheus install script" ansible.builtin.get_url: url: https://raw.githubusercontent.com/perforce/p4prometheus/master/scripts/install_p4prom.sh dest: /p4/install_p4prom.sh mode: '0755' owner: "{{ perforce_user }}" group: "{{ perforce_group }}" retries: 3 delay: 10 register: p4prom_download until: p4prom_download is not failed - name: "Download p4prometheus install common library" ansible.builtin.get_url: url: https://raw.githubusercontent.com/perforce/p4prometheus/master/scripts/p4prom_common.sh dest: /p4/p4prom_common.sh mode: '0755' owner: "{{ perforce_user }}" group: "{{ perforce_group }}" retries: 3 delay: 10 register: p4prom_common_download until: p4prom_common_download is not failed - name: "Set case_sensitive_server to false in install script" ansible.builtin.replace: path: /p4/install_p4prom.sh regexp: 'case_sensitive_server: true' replace: 'case_sensitive_server: false' when: p4_case_handling.stdout == "insensitive" - name: "Set output_cmds_by_ip to true in install script" ansible.builtin.replace: path: /p4/install_p4prom.sh regexp: 'output_cmds_by_ip: false' replace: 'output_cmds_by_ip: true' - name: "Run the p4prometheus install script" ansible.builtin.command: "/p4/install_p4prom.sh {{ perforce_id }} -m {{ p4prometheus_metrics_dir }}" args: # The installer drops the p4prometheus binary here; skip the re-run once it # exists so the task is idempotent. (Re-run the install by removing the # binary or with install_p4prom.sh directly when upgrading p4prometheus.) creates: "/usr/local/bin/p4prometheus" - name: "Create p4prometheus location file" ansible.builtin.template: src: "./p4prometheus_location.j2" dest: "{{ p4prometheus_metrics_dir }}/location.prom" owner: "{{ perforce_user }}" group: "{{ perforce_group }}" mode: '0644'