oveits / openshift-terraform-ansible_installer

2 stars 0 forks source link

Error: 'failed expects first param is a dict' #7

Closed oveits closed 6 years ago

oveits commented 7 years ago

Ansible installation fails with following log:

ansible-playbook -i $DIR/inventory --become --private-key=${key_path} $DIR/openshift-ansible/playbooks/byo/config.yml | tee $DIR/2_install_openshift_via_ansible.log
...

TASK [openshift_manage_node : Label nodes] *************************************
fatal: [ec2-35-156-2-76.eu-central-1.compute.amazonaws.com]: FAILED! => {"failed": true, "msg": "|failed expects first param is a dict"}
oveits commented 7 years ago

The problem is caused by a wrong syntax in the inventory file:

correct:

[nodes]
ec2-35-156-161-11.eu-central-1.compute.amazonaws.com openshift_node_labels="{'region': 'infra', 'zone': 'default'}"
ec2-35-156-161-17.eu-central-1.compute.amazonaws.com openshift_node_labels="{'region': 'infra', 'zone': 'default'}"

wrong (missing single quotes):

[nodes]
ec2-35-156-161-11.eu-central-1.compute.amazonaws.com openshift_node_labels="{region: infra, zone: default}"
ec2-35-156-161-17.eu-central-1.compute.amazonaws.com openshift_node_labels="{region: infra, zone: default}"

This is caused by the last change https://github.com/oveits/openshift-terraform-ansible_installer/commit/a592d6ac090a6b2ea9751f2ebf6665da34361093 with automatic adaption of the inventory file.

oveits commented 7 years ago

Proposed solution: in 2_install_openshift_via_ansible.sh change line

NODES=`cat terraform.tfstate | grep ec2- | awk -F '"' -v master="$MASTER" ' $0 !~ master { print $4" openshift_node_labels=\"{\'region\': \'infra\', \'zone\': \'default\'}\"" }'`

by

NODES=`cat terraform.tfstate | grep ec2- | awk -F '"' -v master="$MASTER" ' $0 !~ master { print $4" openshift_node_labels=\"{'\''region'\'': '\''infra'\'', '\''zone'\'': '\''default'\''}\"" }'`

Note: for AWK, single quotes ' must be escaped with '\''; i,e, end quote ', escaped quote \' and start quote'. I had assumed that a single escape \' is sufficient, but that is not true. '\'' looks weird, but it works. See http://stackoverflow.com/questions/9899001/how-to-escape-single-quote-in-awk-inside-printf.