DEV Community

Query Filter
Query Filter

Posted on

docker8


You can pass variables directly when calling the playbook:

1)
    ansible-playbook release.yml -e "target_env=qa version=1.2.3 db_host=eqtpsqa58"

    or

    ansible-playbook deploy_comet.yml -i inventory.ini -e "env_limit=dev"

2)
    If you have a file called build.properties, you can tell Ansible YAML to load it:

    vars_files:
  - "/path/to/build.properties"

  Note: Ansible prefers YAML for variable files, but it can parse standard key-value pairs if needed.

3)
  If Tekton sets an environment variable like $BUILD_ID, Ansible YAML can read it directly:

  - name: Print the build ID
  debug:
    msg: "Deploying build number {{ lookup('env', 'BUILD_ID') }}"

4) YAML
---
- name: Deploy COMET RPM to Target Environment
  hosts: "{{ env_limit }}"  # We pass this variable (dev, qa, or prod) at runtime
  become: yes               # Run as root/sudo
Enter fullscreen mode Exit fullscreen mode

Top comments (0)