1- name: Configuring a handler with missing tcp parameters should fail 2 sensu_handler: 3 name: "tcp" 4 type: "tcp" 5 register: failure 6 ignore_errors: true 7 8- name: Assert that configuring a handler with missing tcp parameters fails 9 assert: 10 that: 11 - failure is failed 12 - "'the following are missing: socket' in failure['msg']" 13 14- name: Configure a tcp handler 15 sensu_handler: 16 name: "tcp" 17 type: "tcp" 18 socket: 19 host: 127.0.0.1 20 port: 8000 21 register: handler 22 23- name: Retrieve configuration file 24 slurp: 25 src: "{{ handler['file'] }}" 26 register: handler_config 27 28- name: Validate tcp handler return data 29 assert: 30 that: 31 - "handler is successful" 32 - "handler is changed" 33 - "handler['name'] == 'tcp'" 34 - "handler['file'] == '/etc/sensu/conf.d/handlers/tcp.json'" 35 - "handler['config']['type'] == 'tcp'" 36 - "handler['config']['socket']['host'] == '127.0.0.1'" 37 - "handler['config']['socket']['port'] == 8000" 38 - "handler['config']['handle_flapping'] == false" 39 - "handler['config']['handle_silenced'] == false" 40 41- name: Assert that the handler configuration file is actually configured properly 42 vars: 43 config: "{{ handler_config.content | b64decode | from_json }}" 44 assert: 45 that: 46 - "'tcp' in config['handlers']" 47 - "config['handlers']['tcp']['type'] == 'tcp'" 48 - "config['handlers']['tcp']['socket']['host'] == '127.0.0.1'" 49 - "config['handlers']['tcp']['socket']['port'] == 8000" 50 - "config['handlers']['tcp']['handle_flapping'] == false" 51 - "config['handlers']['tcp']['handle_silenced'] == false" 52