Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

bad trap error with aws/terraform example #323

Open
@mbarretta

Description

@mbarretta

https://github.com/elastic/examples/tree/master/Cloud%20Enterprise/Getting%20Started%20Examples/aws/terraform

When running on OSX, all is well. When running on Ubuntu, the following error is displayed:

null_resource.run-ansible (local-exec): Executing: ["/bin/sh" "-c" "#!/usr/bin/env bash\n\n# Short form: set -u\nset -o nounset\n# Short form: set -e\nset -o errexit\n\n# Print a helpful message if a pipeline with non-zero exit code causes the\n# script to exit as described above.\ntrap 'echo \"Aborting due to errexit on line $LINENO. Exit code: $?\" >&2' ERR\n\n# Allow the above trap be inherited by all functions in the script.\n#\n# Short form: set -E\nset -o errtrace\n\n# Return value of a pipeline is the value of the last (rightmost) command to\n# exit with a non-zero status, or zero if all commands in the pipeline exit\n# successfully.\nset -o pipefail\n\n# Set $IFS to only newline and tab.\n#\n# http://www.dwheeler.com/essays/filenames-in-shell.html\nIFS=$'\\n\\t'\n\n###############################################################################\n# Program Functions\n###############################################################################\n\n_verify_ansible() {\nif [ -x \"$(command -v ansible-galaxy)\" ]; then\n\t# install role\n  ansible-galaxy install git+https://github.com/elastic/ansible-elastic-cloud-enterprise.git\nelse\n  echo \"ERROR: Ansible isn't installed on this machine, aborting ece installation\"\n  exit 1\nfi\n}\n\n_write_ansible_playbook() {\ncat << PLAYBOOK > ./ece.yml\n---\n- hosts: primary\n  gather_facts: true\n  roles:\n    - ansible-elastic-cloud-enterprise\n  vars:\n    ece_primary: true\n    ece_version: 2.5.0\n\n- hosts: secondary\n  gather_facts: true\n  roles:\n    - ansible-elastic-cloud-enterprise\n  vars:\n    ece_roles: [director, coordinator, proxy, allocator]\n    ece_version: 2.5.0\n\n- hosts: tertiary\n  gather_facts: true\n  roles:\n    - ansible-elastic-cloud-enterprise\n  vars:\n    ece_roles: [director, coordinator, proxy, allocator]\n    ece_version: 2.5.0\nPLAYBOOK\n}\n\n_write_ansible_hosts() {\ncat << HOSTS_FILE > ./hosts\n[primary]\nec2-52-90-75-186.compute-1.amazonaws.com\n\n[primary:vars]\navailability_zone=us-east-1a\n\n[secondary]\nec2-107-23-165-2.compute-1.amazonaws.com\n\n[secondary:vars]\navailability_zone=us-east-1b\n\n[tertiary]\nec2-35-175-229-42.compute-1.amazonaws.com\n\n[tertiary:vars]\navailability_zone=us-east-1c\n\n[aws:children]\nprimary\nsecondary\ntertiary\n\n[aws:vars]\nansible_ssh_private_key_file=~/.ssh/barretta-aws-east.pem\nansible_user=centos\nansible_become=yes\ndevice_name=nvme0n1\nHOSTS_FILE\n}\n\n_run_ansible() {\n  export ANSIBLE_HOST_KEY_CHECKING=False\n  ansible-playbook -i hosts ece.yml\n}\n\n###############################################################################\n# Main\n###############################################################################\n\n# _main()\n#\n# Usage:\n#   _main [<options>] [<arguments>]\n#\n# Description:\n#   Entry point for the program, handling basic option parsing and dispatching.\n_main() {\n    _verify_ansible\n    _write_ansible_playbook\n    _write_ansible_hosts\n    sleep 90\n    _run_ansible\n}\n\n# Call `_main` after everything has been defined.\n_main \"$@\"\n"] 
_main "$@"': exit status 1. Output: trap: ERR: bad trap

Is there something with linux and traps that require a different definition than is present in https://github.com/elastic/examples/blob/master/Cloud%20Enterprise/Getting%20Started%20Examples/aws/terraform/ansible-install.sh#L4-L10 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions