oveits / openshift-terraform-ansible_installer

2 stars 0 forks source link

Error message: 'ssh: Could not resolve hostname true: Name or service not known' #8

Closed oveits closed 6 years ago

oveits commented 7 years ago

We can see that 2_docker...sh runs fine until the ansible-playbook finisches (failed=0). However, after that an ssh command seems to fail.

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
...
PLAY RECAP *********************************************************************
ec2-35-156-161-11.eu-central-1.compute.amazonaws.com : ok=143  changed=9    unreachable=0    failed=0
ec2-35-156-161-17.eu-central-1.compute.amazonaws.com : ok=138  changed=9    unreachable=0    failed=0
ec2-35-156-2-76.eu-central-1.compute.amazonaws.com : ok=313  changed=34   unreachable=0    failed=0
localhost                  : ok=12   changed=6    unreachable=0    failed=0

Loaded plugins: fastestmirror, ovl
Cleaning repos: base epel extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
ssh: Could not resolve hostname true: Name or service not known
######################################################################
# Could not create test user on OpenShift Master!!!
# Try connecting to the OpenShift master via:
#   ssh -t -i .aws/SSH_Key.pem centos@true
# and try adding the user manually via:
#   sudo htpasswd -b /etc/origin/openshift-passwd test SQ5ciX
######################################################################
oveits commented 7 years ago

The problem is caused by the line

# file: 2_install_openshift_via_ansible.sh
...
MASTERIP=`cat ./terraform.tfstate | grep public_ip | awk -F '"' '{print $4; exit}'`

returning true instead of an IP address.

We will see, why:

$ cat ./terraform.tfstate | grep public_ip
                            "associate_public_ip_address": "true",
                            "public_ip": "35.156.2.76",
                            "associate_public_ip_address": "true",
                            "public_ip": "35.156.161.11",
                            "associate_public_ip_address": "true",
                            "public_ip": "35.156.161.17",
                            "map_public_ip_on_launch": "true",

I need to make sure that I only get the value of public_ip, but not the value of associate_public_ip_address.

This is better:

cat ./terraform.tfstate | grep '"public_ip"'

Trying:

$ MASTERIP=`cat ./terraform.tfstate | grep '"public_ip"' | awk -F '"' '{print $4; exit}'`
$ echo $MASTERIP
35.156.2.76

Perfect!