migtools / labs

Tutorials and labs focused on educating users
Apache License 2.0
11 stars 18 forks source link

The Bookbag does not become available #67

Open tux1980 opened 2 years ago

tux1980 commented 2 years ago

Hi

fatal: [localhost]: FAILED!

After type in the OCP3 FQDN in the appropriate OCP4 Bastion Host it is running some tests with positiv results but after sometime the Ansible Playbook obviously fails.

Do you have any Idea what that might cause? Because otherwise the env is working fine, but we do not have the Instructions for the Lab - is there maybe some "general" URL we might use?

Thanks!

Please enter your OCP3 bastion hostname. That is the one you received FOR YOUR OCP3 environment: master1.w6pbq.sandbox225.opentlc.com
Your OCP3 GUID is w6pbq. Working... Checking cluster connectivity cluster.info Grabbing cluster info from OCP3 cluster Login successful.


TASK [Reading cluster information file] *** fatal: [localhost]: FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'ini'. Error was a <class 'configparser.DuplicateSectionError'>, original message: While reading from '<???>' [line 11]: section 'OCP3' already exists"}

markusjnagel commented 2 years ago

I've had the above error (hi @tux1980 ) after trying to re-run the first failed playbook run (that never returned). Logging in to the bastion host again (and providing the OCP3 bastion again) leads to this error - "section OCP3 already exists".

I have thrown my two clusters away and re-provisioned again, but the same initial error occurs again, which is:

TASK [set_fact] ****************************************************************
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'ansible_user' is undefined\n\nThe error appears to be in '/home/lab-user/bookbag.yml': line 32, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n  - set_fact:\n    ^ here\n"}

The full transcript is here...:

[🎩︎mnagel ~]$ ssh lab-user@bastion.fbg9h.sandbox1700.opentlc.com
The authenticity of host 'bastion.fbg9h.sandbox1700.opentlc.com (3.20.165.218)' can't be established.
ED25519 key fingerprint is SHA256:ASIg6ovWPZRUrclf9x/Nv48RSf8Gs3zKdAMUEGYFzY0.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'bastion.fbg9h.sandbox1700.opentlc.com' (ED25519) to the list of known hosts.
lab-user@bastion.fbg9h.sandbox1700.opentlc.com's password: 

    β–ˆβ–ˆβ•—    β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—      β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
    β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•
    β–ˆβ–ˆβ•‘ β–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
    β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•
    β•šβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
     β•šβ•β•β•β•šβ•β•β• β•šβ•β•β•β•β•β•β•β•šβ•β•β•β•β•β•β• β•šβ•β•β•β•β•β• β•šβ•β•β•β•β•β• β•šβ•β•     β•šβ•β•β•šβ•β•β•β•β•β•β•

                        β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
                        β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•—
                           β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘
                           β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘
                           β–ˆβ–ˆβ•‘   β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
                           β•šβ•β•    β•šβ•β•β•β•β•β•

        β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—    β–ˆβ–ˆβ•—      β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
        β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ•”β•β•β•β•β•    β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
        β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘         β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
        β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘         β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—
        β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—    β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
        β•šβ•β•     β•šβ•β•   β•šβ•β•    β•šβ•β•β•β•β•β•    β•šβ•β•β•β•β•β•β•β•šβ•β•  β•šβ•β•β•šβ•β•β•β•β•β•

   =================================================================

Please enter your OCP3 bastion hostname. 
That is the one you received FOR YOUR OCP3 environment: master1.csbts.sandbox390.opentlc.com
Your OCP3 GUID is csbts. 
Working...
Checking cluster connectivity
Warning: Permanently added 'master1.csbts.sandbox390.opentlc.com,3.21.135.161' (ECDSA) to the list of known hosts.
cluster.info
Grabbing cluster info from OCP3 cluster
Login successful.

You have access to 64 projects, the list has been suppressed. You can list all projects with 'oc projects'

Using project "default".
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'

PLAY [localhost] ***************************************************************

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [fail] ********************************************************************
skipping: [localhost]

TASK [Reading cluster information file] ****************************************
ok: [localhost]

TASK [Creating bookbag project] ************************************************
changed: [localhost]

TASK [set_fact] ****************************************************************
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'ansible_user' is undefined\n\nThe error appears to be in '/home/lab-user/bookbag.yml': line 32, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n  - set_fact:\n    ^ here\n"}

PLAY RECAP *********************************************************************
localhost                  : ok=3    changed=1    unreachable=0    failed=1    skipped=1    rescued=0    ignored=0   

Waiting for Bookbag to become available.......
markusjnagel commented 2 years ago

Hi @tux1980 - not sure if it is still relevant but I was able to solve it (with some help from the lab maintainers, of course :smile: )

It's a little dirty hack, but works. :shrug:

Solving the root cause

For some reason, the ansible_user variable is not set, which causes the playbook bookbag.yml to fail. Setting it in the prepare_station.sh script in the ansible playbook call

    ansible-playbook -e ansible_user=${whoami} -e ocp3_password=$PASSWORD -e ocp4_password=$PASSWORD bookbag.yml > >(tee -a bookbag.log) 2> >(tee -a bookbag_err.log >&2)

resolved the missing variable error, but it wasn't resolved correctly, causing the

- name: "Fetching bookbag repo"
    git:
      repo: "{{ bookbag_repo }}"
      dest: "{{ bookbag_dir }}"
      update: yes

to fail, since it can't write to home/lab-instructions. Must be something very simple, but I didn't want to fiddle around too much with the playbook, so...

Simply setting (hacking) the section with a hard-coded /home/lab-user/lab-instructions

  - set_fact:
      bookbag_repo: "https://github.com/konveyor/labs.git"
      bookbag_dir: "/home/lab-user/lab-instructions"
      bookbag_build_dir: "mtc/bookbag"

solved that for me and it built perfectly.

Resetting after a failed attempt

Until the bookbag has successfully been built and deployed, each new login to the bastion host will again start the script. However, on subsequent attempts, it created error messages ("section 'OCP3' already exists"), because it is fetching the cluster.info file again from OCP3 and appending it, resulting in duplicate [OCP3] entries

To avoid that, remove the fetched file, the logs and restore the original cluster.info

rm cluster.info 
rm cluster.ocp3 
mv cluster.orig cluster.info
rm bookbag_err.log 
rm bookbag.log 
exit

After logging back in, it should now work. At least, it did for me.

HTH

image

joelapatatechaude commented 1 year ago

Confirming that @markusjnagel hack still working in March 2023.