Bug 2218897

Summary: ceph_ansible_extra_vars is exported as YAML, but it should be JSON
Product: Red Hat OpenStack Reporter: Alex Stupnikov <astupnik>
Component: ceph-ansibleAssignee: Manoj Katari <mkatari>
Status: CLOSED NOTABUG QA Contact: Yogev Rabl <yrabl>
Severity: low Docs Contact:
Priority: low    
Version: 16.2 (Train)CC: anbs, fpantano, gfidente, johfulto, mburns, mkatari
Target Milestone: zstreamKeywords: Triaged
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-07-10 14:22:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Alex Stupnikov 2023-06-30 13:31:57 UTC
Description of problem:

According to ansible documentation [1], JSON format should be used to pass non-string values such as Booleans, integers, floats, lists, etc as extra vars. One of our customers tried to use CephAnsibleExtraConfig definition [2] to enable autoscaling for CephFS pools, but failed because ceph_pools definition was treated as ansible.utils.unsafe_proxy.AnsibleUnsafeText.

It looks like this is caused by the way ceph_ansible_extra_vars is generated by TripleO Heat Templates.

Related discussion:
[rhos-tech][ceph-ansible] Need advice about customizing cephfs_pools using THT parameters


[1]
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#defining-variables-at-runtime

[2]
CephAnsibleExtraConfig:
  dashboard_protocol: http
  cephfs_data_pool:
    name: "cephfs_data"
    pg_autoscale_mode: true
    target_size_ratio: 0.0
    rule_name: "replicated_rule"
    size: 2
    min_size: 1
  cephfs_metadata_pool:
    name: "cephfs_metadata"
    pg_autoscale_mode: true
    target_size_ratio: 0.0
    rule_name: "replicated_rule"
    size: 2
    min_size: 1
  cephfs_pools:
    - cephfs_data_pool
    - cephfs_metadata_pool

Version-Release number of selected component (if applicable):
RHOSP 16.2


How reproducible:
Define CephAnsibleExtraConfig as in description and run deployment command


Actual results:
Deployment command will fail with the following error:
2023-06-30 15:47:36,580 p=852187 u=root n=ansible | TASK [ceph-mds : create filesystem pools] **************************************
2023-06-30 15:47:36,580 p=852187 u=root n=ansible | Friday 30 June 2023  15:47:36 +0800 (0:00:00.056)       0:08:10.266 *********** 
2023-06-30 15:47:36,604 p=852187 u=root n=ansible | fatal: [HOSTNAME -> {{ groups[mon_group_name][0] }}]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'name'\n\nThe error appears to be in '/usr/share/ceph-ansible/roles/ceph-mds/tasks/create_mds_filesystems.yml': line 25, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n    - name: create filesystem pools\n      ^ here\n"}

Expected results:
ceph_pools variable is parsed as list by ansible


Additional info:
cat /var/lib/mistral/overcloud/ceph-ansible/extra_vars.yml
cephfs_data_pool:
    min_size: 1
    name: cephfs_data
    pg_autoscale_mode: true
    rule_name: replicated_rule
    size: 2
    target_size_ratio: 0.0
cephfs_metadata_pool:
    min_size: 1
    name: cephfs_metadata
    pg_autoscale_mode: true
    rule_name: replicated_rule
    size: 2
    target_size_ratio: 0.0
cephfs_pools:
- cephfs_data_pool
- cephfs_metadata_pool
container_binary: podman
dashboard_protocol: http
fetch_directory: /var/lib/mistral/overcloud/ceph-ansible/fetch_dir
ireallymeanit: 'yes'

Comment 1 John Fulton 2023-06-30 14:03:06 UTC
Attempting to reproduce with https://review.opendev.org/c/openstack/tripleo-heat-templates/+/882678

Comment 5 Manoj Katari 2023-07-04 15:03:09 UTC
Hi @astupnik ,

Firstly the issue appears irrespective of json or yaml.
Like Francesco stated earlier, actual issue is that the ceph-ansible stable-4.0 mds ansible role cannot handle the suggested extra_vars.yml in this bz.

We used the updated extra_vars.yml [1] in the upstream job and it is successful, refer [2] for logs.

[1] https://zuul.opendev.org/t/openstack/build/1670afc36a7c4ccc94be731bb12d8182/log/logs/undercloud/home/zuul/tripleo-deploy/standalone-ansible-g_rsxcuw/ceph-ansible/extra_vars.yml
[2] https://zuul.opendev.org/t/openstack/build/1670afc36a7c4ccc94be731bb12d8182/log/logs/undercloud/home/zuul/standalone_deploy.log