The test to the loadbalancer itself never fails, and serves the same content as the websites (although host and metadata are a bit different), and I can’t for the life of me figure out the disconnect.
If someone can point me in the right direction it would be appreciated.
All hosts are ubuntu 16.04.01 LTS
hostnames:
loadbalancer - Ansible-nginx
webcluster - AnsibleWeb, AnsibleWeb2
All AWS EC2 instances
The loadbalancer lines in my status playbook:
-
hosts: loadbalancer
tasks: -
name: verify backend index response
uri: url=http://{{item}} return_content=yes
with_items: ‘{{groups.webcluster}}’
register: app_index -
fail: msg=“index failed to return content”
when: “‘Hello, from sunny {{item.item}}!’ not in item.content”
with_items: “{{app_index.results}}”
Output of the play before it stops:
PLAY [loadbalancer] ************************************************************
TASK [setup] *******************************************************************
ok: [Ansible-nginx]
TASK [verify backend index response] *******************************************
ok: [Ansible-nginx] => (item=AnsibleWeb)
ok: [Ansible-nginx] => (item=AnsibleWeb2)
TASK [fail] ********************************************************************
failed: [Ansible-nginx] (item={u’status’: 200, u’content_length’: u’35’, ‘_ansible_item_result’: True, u’date’: u’Sat, 20 Aug 2016 23:26:21 GMT’, ‘_ansible_no_log’: False, u’url’: u’http://AnsibleWeb’, u’changed’: False, u’server’: u’Apache/2.4.18 (Ubuntu)‘, u’content’: u’Hello, from sunny ip-172-31-30-54!\n’, ‘item’: u’AnsibleWeb’, u’connection’: u’close’, u’content_type’: u’text/html; charset=utf-8’, ‘invocation’: {‘module_name’: u’uri’, u’module_args’: {u’directory_mode’: None, u’force’: False, u’remote_src’: None, u’follow_redirects’: u’safe’, u’body_format’: u’raw’, u’owner’: None, u’follow’: False, u’group’: None, u’use_proxy’: True, u’setype’: None, u’content’: None, u’serole’: None, u’status_code’: [200], u’return_content’: True, u’method’: u’GET’, u’body’: None, u’url_username’: None, u’src’: None, u’dest’: None, u’selevel’: None, u’force_basic_auth’: False, u’removes’: None, u’http_agent’: u’ansible-httpget’, u’regexp’: None, u’url_password’: None, u’url’: u’http://AnsibleWeb’, u’backup’: None, u’seuser’: None, u’creates’: None, u’headers’: {}, u’delimiter’: None, u’mode’: None, u’timeout’: 30, u’validate_certs’: True}}, u’msg’: u’OK (35 bytes)‘, u’redirected’: False}) => {“failed”: true, “item”: {“changed”: false, “connection”: “close”, “content”: “Hello, from sunny ip-172-31-30-54!\n”, “content_length”: “35”, “content_type”: “text/html; charset=utf-8”, “date”: “Sat, 20 Aug 2016 23:26:21 GMT”, “invocation”: {“module_args”: {“backup”: null, “body”: null, “body_format”: “raw”, “content”: null, “creates”: null, “delimiter”: null, “dest”: null, “directory_mode”: null, “follow”: false, “follow_redirects”: “safe”, “force”: false, “force_basic_auth”: false, “group”: null, “headers”: {}, “http_agent”: “ansible-httpget”, “method”: “GET”, “mode”: null, “owner”: null, “regexp”: null, “remote_src”: null, “removes”: null, “return_content”: true, “selevel”: null, “serole”: null, “setype”: null, “seuser”: null, “src”: null, “status_code”: [200], “timeout”: 30, “url”: “http://AnsibleWeb”, “url_password”: null, “url_username”: null, “use_proxy”: true, “validate_certs”: true}, “module_name”: “uri”}, “item”: “AnsibleWeb”, “msg”: “OK (35 bytes)”, “redirected”: false, “server”: “Apache/2.4.18 (Ubuntu)”, “status”: 200, “url”: “http://AnsibleWeb”}, “msg”: “index failed to return content”}
failed: [Ansible-nginx] (item={u’status’: 200, u’content_length’: u’35’, ‘_ansible_item_result’: True, u’date’: u’Sat, 20 Aug 2016 23:26:21 GMT’, ‘_ansible_no_log’: False, u’url’: u’http://AnsibleWeb2’, u’changed’: False, u’server’: u’Apache/2.4.18 (Ubuntu)‘, u’content’: u’Hello, from sunny ip-172-31-24-83!\n’, ‘item’: u’AnsibleWeb2’, u’connection’: u’close’, u’content_type’: u’text/html; charset=utf-8’, ‘invocation’: {‘module_name’: u’uri’, u’module_args’: {u’directory_mode’: None, u’force’: False, u’remote_src’: None, u’follow_redirects’: u’safe’, u’body_format’: u’raw’, u’owner’: None, u’follow’: False, u’group’: None, u’use_proxy’: True, u’setype’: None, u’content’: None, u’serole’: None, u’status_code’: [200], u’return_content’: True, u’method’: u’GET’, u’body’: None, u’url_username’: None, u’src’: None, u’dest’: None, u’selevel’: None, u’force_basic_auth’: False, u’removes’: None, u’http_agent’: u’ansible-httpget’, u’regexp’: None, u’url_password’: None, u’url’: u’http://AnsibleWeb2’, u’backup’: None, u’seuser’: None, u’creates’: None, u’headers’: {}, u’delimiter’: None, u’mode’: None, u’timeout’: 30, u’validate_certs’: True}}, u’msg’: u’OK (35 bytes)‘, u’redirected’: False}) => {“failed”: true, “item”: {“changed”: false, “connection”: “close”, “content”: “Hello, from sunny ip-172-31-24-83!\n”, “content_length”: “35”, “content_type”: “text/html; charset=utf-8”, “date”: “Sat, 20 Aug 2016 23:26:21 GMT”, “invocation”: {“module_args”: {“backup”: null, “body”: null, “body_format”: “raw”, “content”: null, “creates”: null, “delimiter”: null, “dest”: null, “directory_mode”: null, “follow”: false, “follow_redirects”: “safe”, “force”: false, “force_basic_auth”: false, “group”: null, “headers”: {}, “http_agent”: “ansible-httpget”, “method”: “GET”, “mode”: null, “owner”: null, “regexp”: null, “remote_src”: null, “removes”: null, “return_content”: true, “selevel”: null, “serole”: null, “setype”: null, “seuser”: null, “src”: null, “status_code”: [200], “timeout”: 30, “url”: “http://AnsibleWeb2”, “url_password”: null, “url_username”: null, “use_proxy”: true, “validate_certs”: true}, “module_name”: “uri”}, “item”: “AnsibleWeb2”, “msg”: “OK (35 bytes)”, “redirected”: false, “server”: “Apache/2.4.18 (Ubuntu)”, “status”: 200, “url”: “http://AnsibleWeb2”}, “msg”: “index failed to return content”}
NO MORE HOSTS LEFT *************************************************************
[WARNING]: Could not create retry file ‘stack_status.retry’. [Errno 2] No such
file or directory: ‘’
PLAY RECAP *********************************************************************
Ansible-nginx : ok=5 changed=1 unreachable=0 failed=1
AnsibleControl : ok=3 changed=0 unreachable=0 failed=0
AnsibleDB : ok=3 changed=1 unreachable=0 failed=0
AnsibleWeb : ok=3 changed=1 unreachable=0 failed=0
AnsibleWeb2 : ok=3 changed=1 unreachable=0 failed=0