Giter Club home page Giter Club logo

Comments (9)

cmoulliard avatar cmoulliard commented on August 25, 2024

I tried this without success

cat <<EOF > openstack/list_images1.yaml
---
- hosts: localhost
  module_defaults:
    group/openstack.cloud.openstack:
      auth_type: "v3applicationcredential"
      auth:
        auth_url: "https://rhos-d.infra.prod.upshift.rdu2.redhat.com:13000/v3"
        application_credential_id: "9c9....0deab6e8"
        application_credential_secret: "Kfi444Nl-...BcnWB05i5X6orgdTjwhRQ1JYQ"
      
  tasks:
    - name: List images
      openstack.cloud.image_info:
        auth: "{{ override_defaults }}"
        filters:
          os_distro: "fedora"
      register: image_info_result

    - name: "Print Openstack output"
      debug:
        var: image_info_result
EOF
ansible-playbook openstack/list_images1.yaml

-->

fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'override_defaults' is undefined. 'override_defaults' is undefined

@jacobdotcosta

from k8s-infra.

jacobdotcosta avatar jacobdotcosta commented on August 25, 2024

This is how I implemented the v3applicationcredential authentication, and it worked.

    - name: List Fedora images
      openstack.cloud.image_info:
        auth_type: "v3applicationcredential"
        auth:
          auth_url: "https://rhos-d.infra.prod.upshift.rdu2.redhat.com:13000"
          application_credential_id: "loremipsumdolorsitametconsecteturadipiscingelit"
          application_credential_secret: "loremipsumdolorsitametconsecteturadipiscingelitseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliqua"
        properties:
          os_distro: "fedora"
      register: image_info_result

@cmoulliard

from k8s-infra.

cmoulliard avatar cmoulliard commented on August 25, 2024

This is how I implemented the v3applicationcredential authentication, and it worked.

That works for me too. This is not the question. The idea is to be able to declare one time the AUTH parameters and to inherit them within the different tasks.

@jacobdotcosta

from k8s-infra.

jacobdotcosta avatar jacobdotcosta commented on August 25, 2024

If you want to define a variable with the authentication information so it is reused you can also do this.

    - name: "Set facts"
      ansible.builtin.set_fact:
        rhos_authentication_type: v3applicationcredential
        rhos_authentication:
          auth_url: "https://rhos-d.infra.prod.upshift.rdu2.redhat.com:13000"
          application_credential_id: "loremipsumdolorsitametconsecteturadipiscingelit"
          application_credential_secret: "loremipsumdolorsitametconsecteturadipiscingelitseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliqua"

    - name: List Fedora images
      openstack.cloud.image_info:
        auth_type: "{{ rhos_authentication_type }}"
        auth: "{{ rhos_authentication }}"
        properties:
          os_distro: "fedora"
      register: image_info_result

@cmoulliard

from k8s-infra.

cmoulliard avatar cmoulliard commented on August 25, 2024

If you want to define a variable with the authentication information so it is reused you can also do this.

What about this where we dont have to pass or override some auth parameters ?

- hosts: localhost
  module_defaults:
    group/openstack.cloud.openstack:
      auth_type: "v3applicationcredential"
      auth:
        auth_url: "https://rhos-d.infra.prod.upshift.rdu2.redhat.com:13000/v3"
        application_credential_id: "9c920....e8"
        application_credential_secret: "Kfi4....hRQ1JYQ"
      
  tasks:
    - name: List images
      openstack.cloud.image_info:
        filters:
          os_distro: "fedora"
      register: image_info_result

@jacobdotcosta

from k8s-infra.

jacobdotcosta avatar jacobdotcosta commented on August 25, 2024

That can only be achieved either by using environment variables or using a named cloud.

From the Ansible docs:

Dictionary containing auth information as needed by the cloud’s auth plugin strategy. 
For the default password plugin, this would contain auth_url, username, password, 
project_name and any information about domains (for example, user_domain_name or 
project_domain_name) if the cloud supports them. For other plugins, this param will 
need to contain whatever parameters that auth plugin requires. This parameter is not 
needed if a named cloud is provided or OpenStack OS_* environment variables are present.

IIUC, named cloud requires having a local clouds.yaml file with the authentication information. Something like:

clouds:
 cloud_name:
    auth:
      project_name: "XXXXXXXXXXXXXXXXXX"
      username: "XXXXXXXXXXXXXXXXXX"
      password: "XXXXXXXXXXXXXXXXXX"
      user_domain_name: "XXXXXXXXXXXXXXXXXX"
      project_domain_name: "XXXXXXXXXXXXXXXXXX"
      auth_url: "XXXXXXXXXXXXXXXXXX"
    region_name: "XXXXXXXXXXXXXXXXXX"
    interface: "XXXXXXXXXXXXXXXXXX"
    identity_api_version: 3

from k8s-infra.

cmoulliard avatar cmoulliard commented on August 25, 2024

That can only be achieved either by using environment variables or using a named cloud.

I dont follow you here. Where are you looking to use clouds.yaml fil ?

from k8s-infra.

jacobdotcosta avatar jacobdotcosta commented on August 25, 2024

I was checking for options where we don't need to pass or override the auth parameters on the playbook and roles, and those are the only 2 options I see.

from k8s-infra.

cmoulliard avatar cmoulliard commented on August 25, 2024

I was checking for options where we don't need to pass or override the auth parameters on the playbook and roles, and those are the only 2 options I see.

I vote to use as no override is needed, can be declared one time = init step, etc

module_defaults:
    group/openstack.cloud.openstack:
...

from k8s-infra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.