diff --git a/tasks/beats-config.yml b/tasks/beats-config.yml index 084c41d..91bef4a 100644 --- a/tasks/beats-config.yml +++ b/tasks/beats-config.yml @@ -22,7 +22,7 @@ - name: Check pid_dir status stat: - path: '{{beats_pid_dir}}' + path: '{{ beats_pid_dir }}' register: pid_stat - name: Create PID Directory @@ -53,7 +53,7 @@ - name: Copy Configuration File for {{ beat }} template: src: beat.yml.j2 - dest: '{{conf_file}}' + dest: '{{ conf_file }}' mode: 0644 force: true owner: root diff --git a/tasks/beats-debian.yml b/tasks/beats-debian.yml index 9a0de68..5bbf7ee 100644 --- a/tasks/beats-debian.yml +++ b/tasks/beats-debian.yml @@ -7,6 +7,7 @@ cache_valid_time: 86400 when: use_repository | bool register: beat_install + until: beat_install is succeeded notify: restart {{ beat }} - name: Debian - Ensure python-urllib3, python-openssl, python-pyasn1 & python-pip are installed @@ -17,6 +18,8 @@ - python-pyasn1 - python-pip state: present + register: libs_install + until: libs_install is succeeded when: - use_repository | bool - ansible_distribution_release == "trusty" @@ -25,6 +28,8 @@ pip: name: ndg-httpsclient state: present + register: ndg_install + until: ndg_install is succeeded when: - use_repository | bool - ansible_distribution_release == "trusty" @@ -33,12 +38,16 @@ apt_key: url: '{{ elastic_repo_key }}' state: present + register: apt_key_install + until: apt_key_install is succeeded when: use_repository | bool - name: Debian - add beats repository apt_repository: repo: 'deb {{ repo_url }} stable main' state: present + register: repo_install + until: repo_install is succeeded when: use_repository | bool - name: Debian - unhold {{ beat }} version for install @@ -48,9 +57,11 @@ - name: Debian - Ensure {{ beat }} is installed apt: name: >- - {{ beat }}{% if beats_version is defined and beats_version != "" %}={{ beats_version }}{% endif %} + {{ beat }}{% if beats_version is defined and beats_version|length>0 %}={{ beats_version }}{% endif %} state: present cache_valid_time: 86400 + register: beat_install + until: beat_install is succeeded when: use_repository | bool notify: restart {{ beat }} @@ -62,19 +73,19 @@ - name: Set os_arch set_fact: os_arch: >- - {{ ansible_architecture == 'x86_64' | ternary("amd64", "i386") }} + {{ ansible_architecture == 'x86_64' | ternary('amd64', 'i386') }} - name: Debian - Download {{ beat }} from url get_url: url: >- {% if custom_package_url is defined %}{{ custom_package_url }}{% - else %}{{ beats_package_url }}/{{ beat }}/{{ beat }}_{{ beats_version }}_{{os_arch}}.deb{% endif %} - dest: '/tmp/{{ beat }}_{{ beats_version }}_{{os_arch}}.deb' + else %}{{ beats_package_url }}/{{ beat }}/{{ beat }}_{{ beats_version }}_{{ os_arch }}.deb{% endif %} + dest: '/tmp/{{ beat }}_{{ beats_version }}_{{ os_arch }}.deb' validate_certs: false when: not use_repository | bool - name: Debian - Ensure {{ beat }} is installed from downloaded package apt: - deb: '/tmp/{{ beat }}_{{ beats_version }}_{{os_arch}}.deb' + deb: '/tmp/{{ beat }}_{{ beats_version }}_{{ os_arch }}.deb' when: not use_repository | bool notify: restart {{ beat }} diff --git a/tasks/beats-redhat.yml b/tasks/beats-redhat.yml index 4e7e4b7..155a152 100644 --- a/tasks/beats-redhat.yml +++ b/tasks/beats-redhat.yml @@ -1,41 +1,52 @@ --- - - name: Ensure libselinux-python on CentOS 6.x - yum: name=libselinux-python state=present update_cache=yes - when: ( ansible_distribution == "CentOS" ) and ( ansible_distribution_major_version == "6" ) + yum: + name: libselinux-python + state: present + update_cache: true + register: libselinux_install + until: libselinux_install is succeeded + when: + - ansible_distribution == "CentOS" + - ansible_distribution_major_version == "6" - name: Redhat - add beats repository - template: src=beats.repo.j2 dest=/etc/yum.repos.d/beats.repo + template: + src: beats.repo.j2 + dest: /etc/yum.repos.d/beats.repo when: use_repository - name: RedHat - install yum-version-lock - yum: name=yum-plugin-versionlock state=present update_cache=yes + yum: + name: yum-plugin-versionlock + state: present + update_cache: true -- name: RedHat - unlock {{beat}} for install - shell: yum versionlock delete {{beat}} || true - changed_when: False +- name: RedHat - unlock {{ beat }} for install + shell: yum versionlock delete {{ beat }} || true + changed_when: false -- name: RedHat - Ensure {{beat}} is installed +- name: RedHat - Ensure {{ beat }} is installed yum: name: >- - {{beat}}{% if beats_version is defined and beats_version != "" %}-{{ beats_version }}{% endif %} + {{ beat }}{% if beats_version is defined and beats_version != "" %}-{{ beats_version }}{% endif %} state: present update_cache: true when: use_repository - notify: restart {{beat}} + notify: restart {{ beat }} -- name: RedHat - lock {{beat}} version +- name: RedHat - lock {{ beat }} version shell: >- yum versionlock add - {{beat}}{% if beats_version is defined and beats_version != "" %}-{{ beats_version }}{% endif %} + {{ beat }}{% if beats_version is defined and beats_version != "" %}-{{ beats_version }}{% endif %} when: version_lock - changed_when: False + changed_when: false -- name: RedHat - Install {{beat}} from url +- name: RedHat - Install {{ beat }} from url yum: name: >- {% if custom_package_url is defined %}{{ custom_package_url }}{% - else %}{{ beats_package_url }}/{{beat}}-{{ beats_version }}-{{ansible_architecture}}.rpm{% endif %} + else %}{{ beats_package_url }}/{{ beat }}-{{ beats_version }}-{{ ansible_architecture }}.rpm{% endif %} state: present when: not use_repository - notify: restart {{beat}} + notify: restart {{ beat }}