Code Monkey home page Code Monkey logo

Comments (3)

freemanjp avatar freemanjp commented on July 17, 2024 1

Yeah, include_role also works, but the advantage of the approach I suggested is it allows you to sequence gantsign.oh-my-zsh relative to other roles in the playbook in the normal way. With include_role you're limited to before (pre_tasks) or after (tasks or post_tasks) all the other roles in the playbook (unless you invoke them with include_role as well).

from ansible-role-oh-my-zsh.

freemanjp avatar freemanjp commented on July 17, 2024

Hi @Gictorbit, unfortunately, loop doesn't work with Ansible roles (only with tasks). Try the following instead:

- name: setup ohmyzsh for users
  hosts: all
  vars:
    userlist:
      - username: "viktor"
        password: "viktor123"
  become: yes
  pre_tasks:
    - name: build oh_my_zsh_users 
      set_fact:
        oh_my_zsh_users: '{{ (oh_my_zsh_users | default([])) + [oh_my_zsh_user] }}'
      vars:
        oh_my_zsh_user:
          username: '{{ item.username }}'
          oh_my_zsh:
            theme: gnzh
            plugins:
              - git
              - zsh-syntax-highlighting
              - zsh-autosuggestions
              - docker
      loop: '{{ userlist }}'
  roles:
    - role: gantsign.oh-my-zsh
      users: '{{ oh_my_zsh_users }}'

from ansible-role-oh-my-zsh.

Gictorbit avatar Gictorbit commented on July 17, 2024

Thank you, I also asked this question in stack overflow and solved this using include_role you can check that from link below:
stack overflow

from ansible-role-oh-my-zsh.

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.