Skip to content

Commit

Permalink
Merge #192: Task retries on connection failure (Implements #151)
Browse files Browse the repository at this point in the history
Add task retries in case of connection failure
  • Loading branch information
armab authored Apr 23, 2018
2 parents 02bb9d2 + 512888e commit f89ab61
Show file tree
Hide file tree
Showing 22 changed files with 190 additions and 4 deletions.
11 changes: 11 additions & 0 deletions roles/bwc/tasks/bwc_repos_apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
with_items:
- debian-archive-keyring
- apt-transport-https
register: _task
retries: 5
delay: 3
until: _task is succeeded

# This is the exact key as the open source repo but this behavior might change.
- name: Add keys to keyring
Expand All @@ -16,6 +20,10 @@
id: 418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB
url: https://packagecloud.io/StackStorm/{{ bwc_repo }}/gpgkey
state: present
register: _task
retries: 5
delay: 3
until: _task is succeeded

- name: "Add packagecloud.io repository: StackStorm/{{ bwc_repo }}"
become: yes
Expand All @@ -26,3 +34,6 @@
state: present
update_cache: yes
register: added_bwc_deb_repository
retries: 5
delay: 3
until: added_bwc_deb_repository is succeeded
4 changes: 4 additions & 0 deletions roles/bwc/tasks/bwc_repos_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "name={{ ansible_nodename }}"
register: _task
retries: 5
delay: 3
until: _task is succeeded

- name: Read bwc_read_token from file
become: yes
Expand Down
4 changes: 4 additions & 0 deletions roles/bwc/tasks/bwc_repos_yum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
yum:
name: ca-certificates
state: latest
register: _task
retries: 5
delay: 3
until: _task is succeeded
tags: skip_ansible_lint

- name: "Add packagecloud.io repository: StackStorm/{{ bwc_repo }}"
Expand Down
9 changes: 9 additions & 0 deletions roles/bwc/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
name: bwc-enterprise
state: latest
register: bwc_installed
retries: 5
delay: 3
until: bwc_installed is succeeded
when: bwc_version == "latest"
tags:
- bwc
Expand All @@ -28,6 +31,9 @@
name: bwc-enterprise
state: present
register: bwc_installed
retries: 5
delay: 3
until: bwc_installed is succeeded
when: bwc_version == "present"
tags:
- bwc
Expand All @@ -39,6 +45,9 @@
name: bwc-enterprise{{ '-' if ansible_pkg_mgr == 'yum' else '=' }}{{ bwc_version }}-{{ bwc_revision }}
state: present
register: bwc_installed
retries: 5
delay: 3
until: bwc_installed is succeeded
when:
- bwc_version != "latest"
- bwc_version != "present"
Expand Down
4 changes: 4 additions & 0 deletions roles/epel/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@
yum:
name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm"
state: present
register: _task
retries: 5
delay: 3
until: _task is succeeded
when: ansible_os_family == "RedHat" and not epel_installed.stat.exists
tags: epel
8 changes: 8 additions & 0 deletions roles/mongodb/tasks/mongodb_apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
keyserver: "hkp://keyserver.ubuntu.com:80"
id: "{{ mongodb_apt_keys[mongodb_major_minor_version] }}"
state: present
register: _task
retries: 5
delay: 3
until: _task is succeeded
tags: [databases, mongodb]

- name: apt | Add mongodb repository
Expand All @@ -20,6 +24,10 @@
apt:
name: "{{ item }}={{ mongodb_version }}*"
state: present
register: _task
retries: 5
delay: 3
until: _task is succeeded
with_items:
# re-installing different version of 'mongodb-org' meta package doesn't automatically
# upgrade or downgrade its dependencies. So we need to explicitly list them one-by-one.
Expand Down
16 changes: 15 additions & 1 deletion roles/mongodb/tasks/mongodb_yum.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
---
- name: yum | Install mongodb dependencies
become: yes
yum: name={{item}} state=present
yum:
name: "{{ item }}"
state: present
register: _task
retries: 5
delay: 3
until: _task is succeeded
with_items:
# Failed to validate the SSL certificate for www.mongodb.org:443. Make sure your managed systems have a valid CA certificate installed. If the website serving the url uses SNI you need python >= 2.7.9 on your managed machine or you can install the `urllib3`, `pyopenssl`, `ndg-httpsclient`, and `pyasn1` python modules to perform SNI verification in python >= 2.6. You can use validate_certs=False if you do not need to confirm the servers identity but this is unsafe and not recommended. Paths checked for this platform: /etc/ssl/certs, /etc/pki/ca-trust/extracted/pem, /etc/pki/tls/certs, /usr/share/ca-certificates/cacert.org, /etc/ansible
- python-urllib3
Expand All @@ -14,6 +20,10 @@
rpm_key:
key: https://www.mongodb.org/static/pgp/server-{{ mongodb_major_minor_version }}.asc
state: present
register: _task
retries: 5
delay: 3
until: _task is succeeded
tags: [databases, mongodb]

- name: yum | Add mongodb repository
Expand All @@ -36,6 +46,10 @@
# TODO: Allow yum downgrade since Ansible 2.4
# https://github.com/ansible/ansible/pull/21516
# allow_downgrade: yes
register: _task
retries: 5
delay: 3
until: _task is succeeded
notify:
- restart mongodb
tags: [databases, mongodb]
8 changes: 8 additions & 0 deletions roles/nginx/tasks/nginx_apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
url: http://nginx.org/keys/nginx_signing.key
id: 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
state: present
register: _task
retries: 5
delay: 3
until: _task is succeeded
tags: nginx

- name: Add nginx repos
Expand All @@ -19,6 +23,10 @@
apt:
name: nginx
state: present
register: _task
retries: 5
delay: 3
until: _task is succeeded
tags: nginx

- name: Remove default site
Expand Down
11 changes: 11 additions & 0 deletions roles/nginx/tasks/nginx_yum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
rpm_key:
key: http://nginx.org/keys/nginx_signing.key
state: present
register: _task
retries: 5
delay: 3
until: _task is succeeded
tags: nginx

- name: Add nginx repos
Expand All @@ -23,6 +27,10 @@
name: nginx
state: present
disablerepo: epel
register: _task
retries: 5
delay: 3
until: _task is succeeded
tags: nginx

- name: Remove default site
Expand All @@ -38,6 +46,9 @@
name: libsemanage-python, libselinux-python
state: present
register: nginx_selinux_dependencies
retries: 5
delay: 3
until: nginx_selinux_dependencies is succeeded
tags: nginx

- name: Update SELinux facts after installing dependencies
Expand Down
16 changes: 13 additions & 3 deletions roles/nodejs/tasks/nodejs_apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
apt:
name: apt-transport-https
state: present
register: _task
retries: 5
delay: 3
until: _task is succeeded
tags: nodejs

- name: Add nodesource key
Expand All @@ -11,20 +15,26 @@
url: https://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0x1655A0AB68576280
id: "68576280"
state: present
register: _task
retries: 5
delay: 3
until: _task is succeeded
tags: nodejs

- name: Add nodesource repos debs
become: yes
apt_repository:
repo: "{{ item }}"
repo: "deb https://deb.nodesource.com/node_{{ nodejs_major_version }}.x {{ ansible_distribution_release }} main"
state: present
with_items:
- "deb https://deb.nodesource.com/node_{{ nodejs_major_version }}.x {{ ansible_distribution_release }} main"
tags: nodejs

- name: Install nodejs
become: yes
apt:
name: nodejs={{ nodejs_major_version }}.*
state: present
register: _task
retries: 5
delay: 3
until: _task is succeeded
tags: nodejs
8 changes: 8 additions & 0 deletions roles/nodejs/tasks/nodejs_yum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
rpm_key:
key: http://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL
state: present
register: _task
retries: 5
delay: 3
until: _task is succeeded
tags: nodejs

- name: Add nodesource repo
Expand All @@ -21,4 +25,8 @@
# TODO: Allow yum downgrade since Ansible 2.4
# https://github.com/ansible/ansible/pull/21516
# allow_downgrade: yes
register: _task
retries: 5
delay: 3
until: _task is succeeded
tags: nodejs
4 changes: 4 additions & 0 deletions roles/postgresql/tasks/postgresql_apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
apt:
name: postgresql
state: installed
register: _task
retries: 5
delay: 3
until: _task is succeeded
tags: [db, postgresql]

- name: apt | Start and Enable PostgreSQL
Expand Down
15 changes: 15 additions & 0 deletions roles/postgresql/tasks/postgresql_yum6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
yum:
name: https://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-3.noarch.rpm
state: installed
register: _task
retries: 5
delay: 3
until: _task is succeeded
when: ansible_distribution == "CentOS"
tags: [db, postgresql]

Expand All @@ -12,6 +16,10 @@
yum:
name: https://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-redhat94-9.4-3.noarch.rpm
state: installed
register: _task
retries: 5
delay: 3
until: _task is succeeded
when: ansible_distribution == "RedHat"
tags: [db, postgresql]

Expand All @@ -20,6 +28,10 @@
yum:
name: libselinux-python
state: installed
register: _task
retries: 5
delay: 3
until: _task is succeeded
tags: [db, postgresql]

- name: yum | Install PostgreSQL-9.4
Expand All @@ -32,6 +44,9 @@
- postgresql94-contrib
- postgresql94-devel
register: install_postgresql
retries: 5
delay: 3
until: install_postgresql is succeeded
tags: [db, postgresql]

- name: yum | Initialize PostgreSQL-9.4
Expand Down
3 changes: 3 additions & 0 deletions roles/postgresql/tasks/postgresql_yum7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
- postgresql-contrib
- postgresql-devel
register: install_postgresql
retries: 5
delay: 3
until: install_postgresql is succeeded
tags: [db, postgresql]

- name: yum | Initialize PostgreSQL
Expand Down
4 changes: 4 additions & 0 deletions roles/rabbitmq/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
package:
name: rabbitmq-server
state: present
register: _task
retries: 5
delay: 3
until: _task is succeeded
notify:
- restart rabbitmq
tags: rabbitmq
Expand Down
8 changes: 8 additions & 0 deletions roles/st2/tasks/auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
with_items:
- python-passlib
- apache2-utils
register: _task
retries: 5
delay: 3
until: _task is succeeded
when: ansible_os_family == 'Debian'

- name: auth | Install auth pre-reqs (RedHat)
Expand All @@ -16,6 +20,10 @@
with_items:
- python-passlib
- httpd-tools
register: _task
retries: 5
delay: 3
until: _task is succeeded
when: ansible_os_family == 'RedHat'

- name: auth | Create htpasswd file
Expand Down
Loading

0 comments on commit f89ab61

Please sign in to comment.