Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Bhaskar Pasupuleti
    @bhaskarproy

    Hi Guys, I need your assistance on Ansible. I am trying to install Debain pacakges using Ansible and I use with_items. Now the list is becoming bigger, so required help on how to ask with_items to read the packages from file. My lines are below. - name: Install Base Packages for
    apt: name={{ item }}
    state=present
    with_items:

    - vim-gtk3
    - apt-transport-https
    - ca-certificates
    - wget
    - software-properties-common
    - locales
    - build-essential
    - acl
    - ntp
    - htop
    - git
    - supervisor
    - python-pip
    - python3-pip
    - nginx
    - build-essential
    - crossbuild-essential-arm64
    - crossbuild-essential-armel
    - crossbuild-essential-armhf
    - crossbuild-essential-powerpc
    - crossbuild-essential-ppc64el
    - crossbuild-essential-mipsel
    - devscripts
    - dh-buildinfo
    - build-essential
    - git
    - cmake
    - g++
    - ccache
    - curl
    - dh-autoreconf
    - lttng-tools
    - liblttng-ust-dev
    - libssh2-1-dev
    - zlib1g-dev
    - liblttng-ust-dev
    - libssh2-1-dev
    - google-mock
    - mysql-server
    - golang-goprotobuf-dev
    - golang-1.8-go
    - fakechroot
    - curl
    - python3-pexpect
    - libboost-all-dev
    - libc-ares-dev
    - libncurses5-dev
    - libncursesw5-dev
    - libreadline-dev
    - libssl-dev:amd64
    - bison
    - libprotobuf-dev
    - libprotoc-dev
    - python-configparser
    - python-pip
    - gdb
    - u-boot-tools
    - screen
    - ruby
    - ruby-dev:amd64
    - ruby-did-you-mean
    - ruby-minitest
    - ruby-net-telnet
    - ruby-power-assert
    - ruby-test-unit
    - ruby2.3
    - ruby2.3-dev:amd64
    - astyle
    - cpp-6-aarch64-linux-gnu
    - cpp-6-arm-linux-gnueabi
    - cpp-6-arm-linux-gnueabihf
    - cpp-aarch64-linux-gnu
    - cpp-arm-linux-gnueabi
    - cpp-arm-linux-gnueabihf
    - g++-6-aarch64-linux-gnu
    - g++-6-arm-linux-gnueabi
    - g++-6-arm-linux-gnueabihf
    - g++-aarch64-linux-gnu
    - g++-arm-linux-gnueabi
    - g++-arm-linux-gnueabihf
    - i2c-tools
    - linux-libc-dev:amd64
    - linux-libc-dev-arm64-cross
    - linux-libc-dev-armel-cross
    - linux-libc-dev-armhf-cross
    - gcc-6-aarch64-linux-gnu
    - gcc-6-arm-linux-gnueabi
    - gcc-6-arm-linux-gnueabihf
    - gcc-aarch64-linux-gnu
    - gcc-arm-linux-gnueabi
    - gcc-arm-linux-gnueabihf
    - libcups2
    - samba
    - samba-common
    - cups
    - tightvncserver
    - winbind
    - libpam-winbind
    - libnss-winbind
    - krb5-config
    - resolvconf
    - realmd
    - sssd
    - sssd-tools
    - adcli
    - krb5-user
    - packagekit
    - samba-common
    - samba-common-bin
    - samba-libs
    - ntp

    tags:

    - packages
    Nicholas Amorim
    @nicholasamorim

    @drewmullen My specific example (although I've heard other people doing the same albeit through much more convoluted ways) is making sure that a given playbook runs against a host that is available for sure.

    An example: automated deploys. Our registry informs our orchestrator (stackstorm) that a new image is available to be deployed. We use Docker Swarm, so Ansible needs to run a playbook against any Swarm manager host but only once (run_once: true). We have 5 managers and there's no guarantee that all 5 will be available, so it'd be useful to have a dynamic host list created from Consul only with healthy hosts.

    Sure there's other ways to accomplish that even using Ansible alone, but as we are moving to using Consul as our DNS/HealthChecker that would be incredibly useful.

    I'm still figuring out how consul_io on Ansible's contrib is supposed to work to see if it suits my use case: create a group of hosts for each service and add inside only hosts that are healthy

    drewmullen
    @drewmullen

    oh man. @nicholasamorim i didnt even see that consul_io thing! the docs are pretty bad though. if you end up using it you should improve those docs lol

    just taking a quick look seems like you need to:

    1. create a consul_io.ini file in the directory youre executing from that contains at least the url (with port). you probably want to pair this down using the options
    2. ansible -i consul_io.py all -m ping
    ecaepp
    @ecaepp
    @bhaskarproy What version of ansible are you using?
    Nicholas Amorim
    @nicholasamorim
    @drewmullen will give it a go this week again. Tried once just to check it out but it failed with some python errors on None/List, apparently expecting some value to be in the KV storage, but I will try again soon. but yeah the docs are awful.
    Bhaskar Pasupuleti
    @bhaskarproy
    @ecaepp I am using ansible 2.8.2
    config file = /etc/ansible/ansible.cfg
    configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
    ansible python module location = /usr/lib/python2.7/site-packages/ansible
    executable location = /usr/bin/ansible
    python version = 2.7.5 (default, Jun 20 2019, 20:27:34) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
    ecaepp
    @ecaepp

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

    # defualts/main.yml
    my_packages:
      - httpd
      - curl
      - fail2ban
      - ...
    
    # tasks/main.yml
    - name: Install some packages
      apt,dnf,yum:
        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

    sumanchowdare
    @sumanchowdare
    @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 ??
    mitun_msdian
    @mitunmbj
    @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
    matrixbot
    @matrixbot
    wilornel Hi #Ansible! I was wondering if you know of a certain repository that contains a playbook for installing kubernetes
    wilornel the binaries
    matrixbot
    @matrixbot
    matrixbot
    @matrixbot
    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
    @mateothegreat
    are you wanting to run it on localhost directly I take it?
    just set host: localhost
    hosts
    reneeshk
    @reneeshk
    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
    self._remove_vars()
    File "/usr/local/lib/python3.6/site-packages/molecule/provisioner/ansible.py", line 782, in _remove_vars
    shutil.rmtree(d)
    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'
    matrixbot
    @matrixbot
    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
    matrixbot
    @matrixbot
    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?
    matrixbot
    @matrixbot
    wilornel It's weird, I see ansible trying to ssh into localhost when clearly packer is building something in aws
    matrixbot
    @matrixbot
    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.
    matrixbot
    @matrixbot
    wilornel Looks like there's an issue on this that was closed by ansible with no further comment? ansible/ansible#31145
    matrixbot
    @matrixbot
    wilornel Alright, I'm getting to it..
    wilornel Now, I don't know the best way to wait.
    gmldba
    @gmldba
    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?
    ecaepp
    @ecaepp
    @reneeshk Going to need some more information about what you are doing and trying to accomplish.
    Terry Odom
    @TerryOdom
    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:
      with_item:
        - { path: C:\ansible\apps\software\Notepad++\npp.7.5.3.Installer.x64.exe, arguments: /S }
                   ^ here
    ecaepp
    @ecaepp
    @TerryOdom try double quoting the path "C:\ansible\apps\software\Notepad++\npp.7.5.3.Installer.x64.exe"
    Terry Odom
    @TerryOdom
    ok, will try that and see. thanks
    Terry Odom
    @TerryOdom
    @ecaepp Thanks again! Just confirming your guidance worked. Much appreciated!!!
    ecaepp
    @ecaepp
    @TerryOdom No problem, if need anything else just let us know. :)
    jghal
    @jghal
    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
    jghal
    @jghal
    blech, seems like {%raw%}{{%endraw%}{{myvar}}{%raw%}}{%endraw%} works but that's really verbose. is there any shorter syntax
    jghal
    @jghal
    {{ myvar | regex_replace('(.*)', '{\1}') }} gets the job done, seems a bit easier to read to me.
    matrixbot
    @matrixbot
    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)