geerlingguy / ansible-role-elasticsearch

Ansible Role - Elasticsearch
https://galaxy.ansible.com/geerlingguy/elasticsearch/
MIT License
185 stars 208 forks source link

Do not fail playbook when state is stopped #92

Closed mpostument closed 1 year ago

mpostument commented 1 year ago

When building ami using packer, i don't need elasticsearch to be started. But even if i set elasticsearch_service_state equal to stopped, handler is still trying to restart elasticsearch and wait_for waiting for elasticsearch to be available. By adding this condition ansible run completed successfully without starting elasticsearch

Before

    elasticsearch.amazon-ebs.elasticsearch: TASK [geerlingguy.elasticsearch : Force a restart if configuration has changed.] ***
    elasticsearch.amazon-ebs.elasticsearch:
    elasticsearch.amazon-ebs.elasticsearch: RUNNING HANDLER [geerlingguy.elasticsearch : restart elasticsearch] ************
    elasticsearch.amazon-ebs.elasticsearch: fatal: [default]: FAILED! => {"changed": false, "msg": "Unable to start service elasticsearch: Job for elasticsearch.service failed because the control process exited with error code. See \"systemctl status elasticsearch.service\" and \"journalctl -xe\" for details.\n"}
    elasticsearch.amazon-ebs.elasticsearch:
    elasticsearch.amazon-ebs.elasticsearch: PLAY RECAP *********************************************************************
    elasticsearch.amazon-ebs.elasticsearch: default                    : ok=10   changed=5    unreachable=0    failed=1    skipped=8    rescued=0    ignored=0

After

  elasticsearch.amazon-ebs.elasticsearch:
    elasticsearch.amazon-ebs.elasticsearch: TASK [../../ansible-role-elasticsearch : Force a restart if configuration has changed.] ***
    elasticsearch.amazon-ebs.elasticsearch:
    elasticsearch.amazon-ebs.elasticsearch: RUNNING HANDLER [../../ansible-role-elasticsearch : restart elasticsearch] *****
    elasticsearch.amazon-ebs.elasticsearch: skipping: [default]
    elasticsearch.amazon-ebs.elasticsearch:
    elasticsearch.amazon-ebs.elasticsearch: TASK [../../ansible-role-elasticsearch : Start Elasticsearch.] *****************
    elasticsearch.amazon-ebs.elasticsearch: changed: [default]
    elasticsearch.amazon-ebs.elasticsearch:
    elasticsearch.amazon-ebs.elasticsearch: TASK [../../ansible-role-elasticsearch : Make sure Elasticsearch is running before proceeding.] ***
    elasticsearch.amazon-ebs.elasticsearch: skipping: [default]
    elasticsearch.amazon-ebs.elasticsearch:
    elasticsearch.amazon-ebs.elasticsearch: PLAY RECAP *********************************************************************
    elasticsearch.amazon-ebs.elasticsearch: default                    : ok=11   changed=6    unreachable=0    failed=0    skipped=10   rescued=0    ignored=0
mpostument commented 1 year ago

Hello @geerlingguy, can you please take a look?

stale[bot] commented 1 year ago

This pull request has been marked 'stale' due to lack of recent activity. If there is no further activity, the PR will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark pull requests as stale.

github-actions[bot] commented 1 year ago

This pr has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.