redhat-cop / ocp4-helpernode

This playbook helps set up an "all-in-one" node, that has all the infrastructure/services in order to install OpenShift 4.
335 stars 301 forks source link

ansible-playbook failure in validate_host_names.yaml #271

Closed bassplay3r closed 2 years ago

bassplay3r commented 2 years ago

I just moved my helper RHEL 8.5 and the ocp4-helpernode playbook is failing with the following, what am I missing?

TASK [Validate values for DNS compatibility] *******************************************************************************************************************************************************************************************************************************************
task path: /root/ocp4-helpernode/tasks/validate_host_names.yaml:1
[WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: item is search('{{ chars }}')

skipping: [localhost] => (item=barnacle.netapp.com)  => {
    "ansible_loop_var": "item",
    "changed": false,
    "item": "barnacle.netapp.com",
    "skip_reason": "Conditional result was False"
}
skipping: [localhost] => (item=helper)  => {
    "ansible_loop_var": "item",
    "changed": false,
    "item": "helper",
    "skip_reason": "Conditional result was False"
}
skipping: [localhost] => (item=bootstrap)  => {
    "ansible_loop_var": "item",
    "changed": false,
    "item": "bootstrap",
    "skip_reason": "Conditional result was False"
}
fatal: [localhost]: FAILED! => {
    "msg": "The conditional check 'item is search('{{ chars }}')' failed. The error was: Unexpected templating type error occurred on ({% if item is search('(\\\\_|\\\\$|\\\\\\|\\\\/|\\\\=|\\\\)|\\\\(|\\\\&|\\\\^|\\\\%|\\\\$|\\\\#|\\\\@|\\\\!|\\\\*)') %} True {% else %} False {% endif %}): expected string or bytes-like object\n\nThe error appears to be in '/root/ocp4-helpernode/tasks/validate_host_names.yaml': line 1, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Validate values for DNS compatibility\n  ^ here\n"
}
[root@helper ocp4-helpernode]# cat vars.yaml
---
disk: vda
ssh_gen_key: false
helper:
  name: "helper"
  ipaddr: "192.168.1.77"
  networkifacename: "ens4"
dns:
  domain: "barnacle.netapp.com"
  clusterid: "civqklxbye56v4y"
  forwarder1: "10.193.159.254"
  forwarder2: "10.102.76.214"
dhcp:
  router: "192.168.1.1"
  bcast: "192.168.1.255"
  netmask: "255.255.255.0"
  poolstart: "192.168.1.10"
  poolend: "192.168.1.30"
  ipid: "192.168.1.0"
  netmaskid: "255.255.255.0"
bootstrap:
  name: "bootstrap"
  ipaddr: "192.168.1.20"
  macaddr: "52:54:00:eb:56:ea"
masters:
  - name: "master0"
    ipaddr: "192.168.1.21"
    macaddr: "52:54:00:ae:42:8d"
  - name: "master1"
    ipaddr: "192.168.1.22"
    macaddr: "52:54:00:cd:5f:e1"
  - name: "master2"
    ipaddr: "192.168.1.23"
    macaddr: "52:54:00:77:7e:ac"
workers:
  - name: "worker0"
    ipaddr: "192.168.1.11"
    macaddr: "52:54:00:5a:18:fa"
  - name: "worker1"
    ipaddr: "192.168.1.12"
    macaddr: "52:54:00:ec:60:5d"
ocp_bios: "https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/latest/latest/rhcos-live-rootfs.x86_64.img"
ocp_initramfs: "https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/latest/latest/rhcos-live-initramfs.x86_64.img"
ocp_install_kernel: "https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/latest/latest/rhcos-live-kernel-x86_64"
ocp_client: "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz"
ocp_installer: "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-install-linux.tar.gz"
[root@helper ocp4-helpernode]# rpm -qa | grep -i ansible
ansible-2.8.18-1.el8ae.noarch
[root@helper ocp4-helpernode]#
ansible-playbook 2.8.18
  config file = /root/ocp4-helpernode/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.6.8 (default, Sep  9 2021, 07:49:02) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
[root@helper ocp4-helpernode]# hostname
helper

[root@helper ocp4-helpernode]# cat /etc/HOSTNAME
cat: /etc/HOSTNAME: No such file or directory

[root@helper ocp4-helpernode]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

[root@helper ocp4-helpernode]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 10.193.159.254
[root@helper ocp4-helpernode]#
salanisor commented 2 years ago

I just tested your vars.yaml from the main branch on commit 2340e5ec5ec298d855cc8125fc4e407590510928

All seems fine. I did invoke some errors via the hostnames to make sure the chars is working; it worked as expected.

[root@bastion ocp4-helpernode]# cat /etc/redhat-release 
Red Hat Enterprise Linux release 8.5 (Ootpa)

[root@bastion ocp4-helpernode]# ansible-playbook --version
ansible-playbook 2.9.27
  config file = /root/ocp4-helpernode/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.6.8 (default, Sep  9 2021, 07:49:02) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]

x

[root@bastion ocp4-helpernode]# ansible-playbook -e @test.yaml tasks/main.yml

PLAY [all] ***********************************************************************************************************************************************************************************************************************************

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

TASK [Validate values for DNS compatibility] *************************************************************************************************************************************************************************************************
[WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: item is search('{{ chars }}')
skipping: [localhost] => (item=barnacle.netapp.com) 
skipping: [localhost] => (item=helper) 
skipping: [localhost] => (item=bootstrap) 
skipping: [localhost] => (item={'name': 'master0', 'ipaddr': '192.168.1.21', 'macaddr': '52:54:00:ae:42:8d'}) 
skipping: [localhost] => (item={'name': 'master1', 'ipaddr': '192.168.1.22', 'macaddr': '52:54:00:cd:5f:e1'}) 
skipping: [localhost] => (item={'name': 'master2', 'ipaddr': '192.168.1.23', 'macaddr': '52:54:00:77:7e:ac'}) 
skipping: [localhost] => (item={'name': 'worker0', 'ipaddr': '192.168.1.11', 'macaddr': '52:54:00:5a:18:fa'}) 
skipping: [localhost] => (item={'name': 'worker1', 'ipaddr': '192.168.1.12', 'macaddr': '52:54:00:ec:60:5d'}) 

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

I'll downgrade Ansible and test that.

bassplay3r commented 2 years ago

Did you install ansible via pip or a rpm based package manager. I'm currently using what the DVD ISO had.

salanisor commented 2 years ago

Installed via RPM. I downgraded to match your Ansible version and replicated the issue. Any chance you can update to Ansible 2.9 latest?

[root@bastion ocp4-helpernode]# ansible-playbook --version
ansible-playbook 2.8.18
  config file = /root/ocp4-helpernode/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.6.8 (default, Sep  9 2021, 07:49:02) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]

[root@bastion ocp4-helpernode]# ansible-playbook -e @test.yaml tasks/main.yml

PLAY [all] ***********************************************************************************************************************************************************************************************************************************

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

TASK [Validate values for DNS compatibility] *************************************************************************************************************************************************************************************************
[WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: item is search('{{ chars }}')

skipping: [localhost] => (item=barnacle.netapp.com) 
skipping: [localhost] => (item=helper) 
skipping: [localhost] => (item=bootstrap) 
fatal: [localhost]: FAILED! => {"msg": "The conditional check 'item is search('{{ chars }}')' failed. The error was: Unexpected templating type error occurred on ({% if item is search('(\\\\_|\\\\$|\\\\\\|\\\\/|\\\\=|\\\\)|\\\\(|\\\\&|\\\\^|\\\\%|\\\\$|\\\\#|\\\\@|\\\\!|\\\\*)') %} True {% else %} False {% endif %}): expected string or bytes-like object\n\nThe error appears to be in '/root/ocp4-helpernode/tasks/validate_host_names.yaml': line 1, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Validate values for DNS compatibility\n  ^ here\n"}

PLAY RECAP ***********************************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0  
bassplay3r commented 2 years ago

I'm not sure I can. I'm behind a proxied environment for the RHEL8 repos. Is there a specific repo I can tell my IT folks to mirror that will allow me to get v2.9?

salanisor commented 2 years ago

it's ansible-2.9-for-rhel-8-x86_64-rpms

christianh814 commented 2 years ago

Thank you @salanisor for pointing this out. But just to clarify, this is called out in the prereqs

However, it might be nice for someone (read: not me because I have no cycles) to do a version check of ansible when you first run the playbook. That would save a lot of folks some headache

bassplay3r commented 2 years ago

FYI we use your stuff in our CI so I would never see it in the docs. Dying early would be helpful. Thanks

bassplay3r commented 2 years ago

Upgrade to ansible-2.9 works for me with a warning TASK [Validate values for DNS compatibility] *** [WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: item is search('{{ chars }}') skipping: [localhost] => (item=barnacle.netapp.com) skipping: [localhost] => (item=helper) skipping: [localhost] => (item=bootstrap) skipping: [localhost] => (item={'name': 'master0', 'ipaddr': '192.168.1.21', 'macaddr': '52:54:00:ae:42:8d'}) skipping: [localhost] => (item={'name': 'master1', 'ipaddr': '192.168.1.22', 'macaddr': '52:54:00:cd:5f:e1'}) skipping: [localhost] => (item={'name': 'master2', 'ipaddr': '192.168.1.23', 'macaddr': '52:54:00:77:7e:ac'}) skipping: [localhost] => (item={'name': 'worker0', 'ipaddr': '192.168.1.11', 'macaddr': '52:54:00:5a:18:fa'}) skipping: [localhost] => (item={'name': 'worker1', 'ipaddr': '192.168.1.12', 'macaddr': '52:54:00:ec:60:5d'})

christianh814 commented 2 years ago

The ansible version check is now in devel #275 ...I'll probably cut a release to main in the coming days as there's been a lot of fixes.

There's probably a better way of checking for RFC 952, and RFC 1123 compliance, but I'll leave that for another time.