GithubHelp home page GithubHelp logo

Comments (5)

ricardclau avatar ricardclau commented on August 22, 2024

Hi @t-yamo

Are you having any issue with such a setup? TBH I have not tried something like this but as long as Ansible supports these definitions it should work as far as I can tell

from deploy.

t-yamo avatar t-yamo commented on August 22, 2024

Hi @ricardclau

Thank you for your response.
This issue is not a setup problem, but is spec of variable.

I avoided this issue by ugly way, but I want to know smart way, so I reported it.

If this issue is a rare case, you can close it.
But I add some description for this issue.

1. ansistrano expects to set own each variables as top level variable

We can not pass variable collection via top level variable.
For passing variable collection via top level variable, ansistrano should use non top level variable.

now: "ansistrano_deploy_to"
wished: "ansistrano.ansistrano_deploy_to" or "ansistrano.deploy_to"

If ansistrano use top level variable as a container for other variables, we can replace variable collection easily.

2. My requirements is "host-A is group-X, host-B is group-Y, and host-C is multiple group-X/Y". and "Each group uses each different ansistrano configuration"

"Can't you switch vars for each groups?"
You are right. and I do configure so.

But there is a host that is joined multiple groups.

In this case, the merged variable collection (for host-C) should includes multiple ansistrano configurations, and it requests that we handle variables by our own way for each ansistrano tasks (or roles).

from deploy.

ricardclau avatar ricardclau commented on August 22, 2024

I am afraid all these questions are about Ansible not about Ansistrano itself but I will do my best to answer :)

So, regarding 1) unless I am confused this is the standard way variables are passed to roles. And we use ansistrano_variable_name to avoid name clashing. AFAIK Ansible does not support collection variables as you wished but I may be wrong

Regarding 2) yes you can do that but the only way would be to create several playbooks in the same playbook file targeting different sets of boxes

So something like this (syntax not checked and I am not sure about the identation in a Github comment but I hope you get the idea):

(deploy-everything-playbook.yml)

---
- hosts: setA
  vars:
    ansistrano_deploy_from: /projects/project-set-a/
    ansistrano_deploy_to: /var/www/projecta
  roles:    
    - carlosbuenosvinos.ansistrano-deploy

- hosts: setB
  vars:
    ansistrano_deploy_from: /projects/project-set-b/
    ansistrano_deploy_to: /var/www/projectb
  roles:    
    - carlosbuenosvinos.ansistrano-deploy

- hosts: setC
  vars:
    ansistrano_deploy_from: /projects/project-set-c/
    ansistrano_deploy_to: /var/www/projectc
  roles:    
    - carlosbuenosvinos.ansistrano-deploy

from deploy.

t-yamo avatar t-yamo commented on August 22, 2024

Thanks to your kind instruction, I understood theory of ansible well.

The way you wrote is exactly the way I am doing now.
It is not easy to organize composite hosts in my environment, but I will think about this configuration more carefully.

thanks!

from deploy.

t-yamo avatar t-yamo commented on August 22, 2024

Additional info: As far as I have investigated, ansible seems to supports passing collection variables.

---
- hosts: all-in-one
  vars:
    xyz:
      api:
        abc:
          xxx: "foo"
          yyy: "bar"
        def:
          zzz: "qqq"
      batch:
        abc:
          yyy: "buz"
  roles:
    - { role: sample, ansistrano: "{{ xyz.api }}" }
    - { role: sample, ansistrano: "{{ xyz.batch }}" }
---
- debug: msg="{{ ansistrano.abc.yyy }}"

output:

TASK: [sample | debug msg="bar"] *****************
ok: [127.0.0.1] => {
    "msg": "bar"
}
...
TASK: [sample | debug msg="buz"] *****************
ok: [127.0.0.1] => {
    "msg": "buz"
}

from deploy.

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.