Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info

    @bhaskarproy In the version of Ansible you are using you can pass an array of packages straight to the name parameter.

    # defualts/main.yml
      - httpd
      - curl
      - fail2ban
      - ...
    # tasks/main.yml
    - name: Install some packages
        name: "{{ my_packages }}"
        state: present

    This method is much more efficient and faster that looping over an array as it equates to $ yum install httpd curl fail2ban on the command line.

    If you still prefer to use a file you can use with_file instead of with_items to loop over the file contents.
    See https://docs.ansible.com/ansible/2.4/playbooks_loops.html#looping-over-files

    @all Hello folks,
    Can anyone help me how to automate fallowing using ansible for eg: assume I have an aws images AMI-123latest and currently I’m already running 10 ec2 instances running on old AMI-123OLD so now i have to automate the upgradation of all 10 ec2 instances to latest AMI-123latest
    suuggest best practies to automate this usecase If possible any sample scripts URL in github ??
    @sumanchowdare bro take a snapshot of the volumes and mount it to the 10Newec2 instance
    just surf for the cli command of adding volume to instance and provke that in ansible scripts
    wilornel Hi #Ansible! I was wondering if you know of a certain repository that contains a playbook for installing kubernetes
    wilornel the binaries
    wilornel Hi Ansible team! Anyone active here?
    wilornel I got this thing with Packer and Ansible that I do not understand
    wilornel I setup the ansible playbook and have packer run it. However, ansible is not running some roles because "hosts: all" does not match localhost. Does anyone know what I'm talking about?
    wilornel Like who assigns what host name is the instance?
    wilornel I don't know if packer does that
    Matthew Davis
    are you wanting to run it on localhost directly I take it?
    just set host: localhost
    Hello all
    Can anyone help me with this error? I'm just pasting last few lines of the error.
    File "/usr/local/lib/python3.6/site-packages/molecule/provisioner/ansible.py", line 713, in manage_inventory
    File "/usr/local/lib/python3.6/site-packages/molecule/provisioner/ansible.py", line 782, in _remove_vars
    File "/usr/lib64/python3.6/shutil.py", line 486, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
    File "/usr/lib64/python3.6/shutil.py", line 444, in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
    File "/usr/lib64/python3.6/shutil.py", line 442, in _rmtree_safe_fd
    os.unlink(name, dir_fd=topfd)
    PermissionError: [Errno 13] Permission denied: 'bitbucket_grp'
    wilornel sounds like you got a permission denied man
    wilornel I feel like we are missing context to help
    wilornel Matthew Davis: Thanks
    wilornel Matthew Davis (Gitter): Thanks
    wilornel I'm getting a new issue
    wilornel amazon-ebs: mkdir: cannot create directory '/root': Permission denied
    wilornel Do you have documentation on permission issues, and ansible trying to create a root dir?
    wilornel what is trying to create a root dir? The roles I'm using?
    wilornel It's weird, I see ansible trying to ssh into localhost when clearly packer is building something in aws
    wilornel I need help with apt_key.. I think that ansible is ssh'ed in as root but I'm getting an error that says that apt-key can only be ran by root.
    wilornel Looks like there's an issue on this that was closed by ansible with no further comment? ansible/ansible#31145
    wilornel Alright, I'm getting to it..
    wilornel Now, I don't know the best way to wait.
    Im using vmware plugin and would like to use the tags for groups. I notice when I run ansible-inventory that tags are included to create groups. How can I add vm tags to the groups?
    @reneeshk Going to need some more information about what you are doing and trying to accomplish.
    Terry Odom
    Hell All. I get the following error when running a playbook but not sure how to address the colon like the error implies. Any suggestions? Thanks in advance
    The offending line appears to be:
        - { path: C:\ansible\apps\software\Notepad++\npp.7.5.3.Installer.x64.exe, arguments: /S }
                   ^ here
    @TerryOdom try double quoting the path "C:\ansible\apps\software\Notepad++\npp.7.5.3.Installer.x64.exe"
    Terry Odom
    ok, will try that and see. thanks
    Terry Odom
    @ecaepp Thanks again! Just confirming your guidance worked. Much appreciated!!!
    @TerryOdom No problem, if need anything else just let us know. :)
    how can I put a variable interpolation inside curly braces? ie command: foobar -arg={{{myvar}}}
    the command expects the opening/closing curly brace in the argument value
    blech, seems like {%raw%}{{%endraw%}{{myvar}}{%raw%}}{%endraw%} works but that's really verbose. is there any shorter syntax
    {{ myvar | regex_replace('(.*)', '{\1}') }} gets the job done, seems a bit easier to read to me.
    dziendobry Hi. I would like to know if someone can help me a on ansible-vault. I have a roles directory here and one role has a vars/main.yml file with the var I need to run my script and there is another file containing sensitive info call vault.yml (encrypted by ansible-vault). I would like to know how to use this vault.yml file. I first try to add it to main.yml using (include_vars: vault.yml) but it is not working (or I'm missing something)
    dziendobry I mean...I'm missing something for sure /o\

    Hi I just bumped on this problem on my project, when I gather_facts, vars interpretation doesn't work anymore. This happends in ansible 2.4 and 2.8
    I'd like to keep vars interpretation when activating fact gathering.

    when gather_facts: no

    TASK [debug] **********************************************************************************************************************************
    ok: [test1-server] => (item={u'path': u'/tmp/somedir/a', u'name': u'some_name'}) => {
        "msg": {
            "name": "some_name", 
            "path": "/tmp/somedir/a"

    when gather_facts: yes

    TASK [debug] **********************************************************************************************************************************
    ok: [test1-server] => (item={u'path': u'{{ dir_a }}', u'name': u'some_name'}) => {
        "msg": {
            "name": "some_name", 
            "path": "{{ dir_a }}"


    - hosts: all
      gather_facts: yes
        type: "dirs"
        dir_a: /tmp/somedir/a
          - name: "some_name"
            path: "{{ dir_a }}"
        - name: debug
            msg: "{{ item }}"
            - "{{ vars[type]}}"
    sorry for the multiple edits
    Jay Carlson
    Is vars a legit way of writing hostvars[inventory_hostname]?
    also I would never name a variable type :-)
    but yes, I can reproduce that