Vyos-vm-images add proxy

Hi,

i am struggling a little bit to add a proxy to the qemu.yml

any idea how to set the environment: "{{proxy_env}}" so that can the chroot env can use the proxy for download the packages.

under vars i added the proxy_env:

here is the guide to add a proxy, sounds easy but there is using a -block
anybody have a idea how to set the proxy correct.

https://docs.ansible.com/ansible/2.7/user_guide/playbooks_environment.html

---
- hosts: qemu
  gather_facts: false
  connection: local
  vars:
    vyos_platform: QEMU
    vyos_format: qcow2
    vyos_qemu_img: /tmp/vyos-{{ vyos_version }}{{ ci_tag  | default()
      }}-{{vyos_disk_size}}G-qemu.qcow2
    vyos_output_img: "{{ vyos_qemu_img }}"
    cloud_init: "false"
    cloud_init_ds_string: "{{ cloud_init_ds | default('NoCloud,ConfigDrive,None') }}"
    cloud_init_ds_list: "{{ cloud_init_ds_string.split(',') }}"
    proxy_env:
      http_proxy: http://proxy:8080
      https_proxy: http://proxy:8080
  tasks:
    - name: Install cobbler
      environment: "{{ proxy_env }}"
      block:
        - include_role:
            name: "{{ roleinputvar }}"
          loop:
            - install-packages
            - download-iso
            - mount-iso
            - get-version
            - create-disk
            - setup-root-partition
            - install-image
            - mount-root-fs
            - install-config
            - install-grub
            - install-persistence-conf
            - install-cloud-init-wrapper
            - install-guest-agent-wrapper
            - install-custom-packages-wrapper
            - fstrim
            - unmount-pre
            - create-pxe-archiveaa
            - unmount-all
            - qemu-qcow2
            - cleanup-ending
            - release
          loop_control:
            loop_var: roleinputvar
      rescue:
        - include_role:
            name: "{{ roleinputvar }}"
          loop:
            - unmount-pre
            - unmount-all
          loop_control:
            loop_var: roleinputvar

Use set system proxy

this is my fix for using a proxy with this yaml.

---
- hosts: qemu
  gather_facts: false
  connection: local
  vars:
    vyos_platform: QEMU
    vyos_format: qcow2
    vyos_qemu_img: "/tmp/vyos-{{ vyos_version }}{{ ci_tag  | default() }}-{{vyos_disk_size}}G-qemu.qcow2"
    vyos_output_img: "{{ vyos_qemu_img }}"
    cloud_init: "false"
    cloud_init_ds_string: "{{ cloud_init_ds | default('NoCloud,ConfigDrive,None') }}"
    cloud_init_ds_list: "{{ cloud_init_ds_string.split(',') }}"
    proxy_server: "http://proxy.example.com:8080"  # Modify this with your proxy server information
  tasks:
    - name: Set proxy environment variables
      shell: |
        echo "http_proxy={{ proxy_server }}" >> /etc/environment
        echo "https_proxy={{ proxy_server }}" >> /etc/environment
        echo "no_proxy=localhost,127.0.0.1" >> /etc/environment
      become: true
      become_user: root

    - include_role:
        name: '{{ roleinputvar }}'
      loop:
        - install-packages
        - download-iso
        - mount-iso
        - get-version
        - create-disk
        - setup-root-partition
        - install-image
        - mount-root-fs
        - install-config
        - install-grub
        - install-persistence-conf
        - install-cloud-init-wrapper
        - install-guest-agent-wrapper
        - install-custom-packages-wrapper
        - fstrim
        - unmount-pre
        - create-pxe-archive
        - unmount-all
        - qemu-qcow2
        - cleanup-ending
        - release
      loop_control:
        loop_var: roleinputvar