Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] running deploy_platform.sh in rover fails after following steps from tutorial #495

Open
opme opened this issue Aug 28, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@opme
Copy link

opme commented Aug 28, 2023

Describe the bug
Trying to follow the steps for building landing zone.

NOTE: Did some experimentation to see which images are working ok and which have errors
aztfmod/rover:1.5.4-2307.2804 has the error. (latest)
aztfmod/rover:1.3.9-2307.0308 has the error (2 months old)
aztfmod/rover:1.2.9-2306.1503] has the error (2 months old)
aztfmod/rover:1.2.9-2306.1405 has the error (3 months old)
aztfmod/rover:1.2.9-2305.0405 that is 4 months old is ok
aztfmod/rover:1.2.9-2303.2414 that is 5 months old is ok
aztfmod/rover:1.2.9-2210.0303 that is one year old is ok.

I see versionAnsible=2.14.4 in the working version and 2.15 in the broken one from the Dockerfile

To Reproduce
Steps to reproduce the behavior:

  1. open dev container in visual studio code
  2. git clone https://github.com/Azure/caf-terraform-landingzones.git landingzones
  3. cd landingzones
  4. git checkout 2203.1
  5. rover login
  6. '/tf/caf/landingzones/templates/platform/deploy_platform.sh'
  7. (accept all defaults for questions)

TASK [include_tasks] ******************************************************************************************************************************
included: /tf/caf/landingzones/templates/ansible/load_alz.yaml for localhost => (item=region1)

TASK [include_tasks] ******************************************************************************************************************************
ERROR! 'with_filetree' is not a valid attribute for a Task

The error appears to be in '/tf/caf/landingzones/templates/ansible/load_deployments_alz.yaml': line 35, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  • name: "Creates directory structure - {{template_lib_folder}}"
    ^ here
    We could be wrong, but this one looks like it might be an issue with
    missing quotes. Always quote template expression brackets when they
    start a value. For instance:

    with_items:
    - {{ foo }}

Should be written as:

with_items:
  - "{{ foo }}"

Expected behavior
script completes without errros

Configuration (please complete the following information):

  • OS and version: [e.g. Windows 10 1909]
  • Version of the rover[e.g. 22] aztfmod/rover:1.5.4-2307.2804
  • Version of the landing zone[e.g. 11] 2203.1
@opme opme added the bug Something isn't working label Aug 28, 2023
@zemosoramesh
Copy link

Any workaround here?

@YSDimov
Copy link

YSDimov commented Nov 9, 2023

@zemosoramesh ive used this code to replace with_filetree. Could you try and reply if it works for you?

`- debug:
msg:
- '{{deployment_mode}}'
- '{{stage}}'
- '{{region}}'
- '{{service}}'

  • name: '{{destination_alz_path}} - Set tfstate_object'
    set_fact:
    tfstate_object: '{{resources[''alz_'' + service].tfstate}}'

  • name: '{{destination_path}}/{{stage}} - Set landingzone file_path'
    set_fact:
    alz_template_folder: '{{public_templates_folder}}/{{ tfstate_object.template_lib_folder}}'
    destination_alz_path: '{{destination_path}}/{{stage}}/{{service}}'

  • name: '{{destination_alz_path}} - Set landingzone file_path'
    set_fact:
    template_lib_folder: '{{alz_template_folder}}/lib/{{ tfstate_object.alz_version }}'

  • name: '{{destination_alz_path}} - Set landingzone file_path'
    set_fact:
    mg: >-
    {{ lookup('template', '{{ template_lib_folder
    }}/archetype_config_overrides.caf.platform.yaml') | from_yaml }}
    mg_custom: >-
    {{ lookup('template', '{{ template_lib_folder
    }}/custom_landing_zones.caf.platform.yaml') | from_yaml }}

  • debug:
    msg:
    - 'tfstate_object: {{resources[''alz_'' + service].tfstate}}'
    - 'destination_alz_path: {{destination_path}}/{{stage}}/{{service}}'
    - >-
    template_lib_folder: {{alz_template_folder}}/lib/{{
    tfstate_object.alz_version }}
    - >-
    alz_template_folder: {{public_templates_folder}}/{{
    tfstate_object.template_lib_folder}}
    - 'tfstate_object: {{resources[''alz_'' + service].tfstate}}'
    - 'mkdir -p {{ destination_alz_path }}/lib/'

  • name: Clean-up destination directory
    shell: |
    rm -rf "{{ destination_alz_path }}"
    when:

      topology.management_groups[region][service].clean_up_destination_folder |
      default(True)
  • find:
    file_type: any
    get_checksum: true
    paths: '{{template_lib_folder}}'
    recurse: true
    register: out

  • debug:
    msg:
    - 'out: {{ out }}'
    - 'test1: {{ out.files | list }}'
    - 'test2: {{ out.files | to_json }}'
    - 'test3: {{ out.files[0] }}'
    - >-
    array: {{ out.files | groupby('path') | map(attribute='1.0.path') | list
    }}

  • name: '{{destination_alz_path}} - Set folder array variable'
    set_fact:
    folder_list: '{{ out.files }}'

  • file:
    path: '{{ destination_alz_path }}/lib'
    state: directory
    name: Create needed target dir

  • loop: '{{ folder_list }}'
    name: 'Creates directory structure - {{template_lib_folder}}'
    shell: >-
    mkdir -p "{{ destination_alz_path }}/lib/{{ item.path |
    regex_replace(template_lib_folder, '') }}"
    when: item.isdir == true

  • ansible.builtin.template:
    dest: >-
    {{ destination_alz_path }}/lib/{{ item.path |
    regex_replace(template_lib_folder, '') }}
    force: 'yes'
    src: '{{ item.path }}'
    loop: '{{ folder_list }}'
    name: ' Lib'
    when:

    • item.isdir == false
    • item.path is not search(".j2")
      item.path is not search(".yaml") or item.path is search(".json") or
      item.path is search(".md")
      topology.management_groups[region][service].update_lib_folder |
      default(True)
  • ansible.builtin.template:
    dest: >-
    {{ destination_alz_path }}/{{ item.path |
    regex_replace(template_lib_folder, '') }}
    force: 'yes'
    src: '{{ item.path }}'
    loop: '{{ folder_list }}'
    name: ' Lib'
    when:

    • item.isdir == false
    • item.path is search(".yaml")
      topology.management_groups[region][service].update_lib_folder |
      default(True)
  • ansible.builtin.template:
    dest: '{{destination_path}}/{{resources[stage + '''' + item].tfstate.config_file}}'
    src: >-
    {{platform_service_folder}}/{{topology.deployments[deployment_mode][stage][region][item]}}
    loop: '{{topology.deployments[deployment_mode][stage][region].keys()}}'
    name: >-
    {{deployment_mode}}/{{stage}}/{{region}}/{{service}} to
    {{destination_path}}/{{'alz
    ' + service}}.yaml`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants