• ansible

    Get systemd services in ansible plays

    Hi, this is a tip to get details about linux (e.g. systemd) services in an ansible play. Just use the ansible service_facts module. You can use it without passing any argument. – name: Populate service facts   ansible.builtin.service_facts: You can access services by using ansible_facts.services. As this is an dictionary, a single service is addressable by using ansible_facts.services[{{ service-name }}]. – name: show all service facts   debug:     var: ansible_facts.services[{{ service_name }}] A few more examples: – name: Retrieve data about single service   debug:     var: ansible_facts.services.httpd – name: get a particular service attribute   debug:     var: ansible_facts.services.httpd.state – name: Test (RHEL7 and higher) if service is up and running   fail:     msg: “Service httpd…

  • ansible,  DevOps

    use ansible module copy instead of template for small files

    In order to adapt files and their content on target servers I am used to using ansible copy module. owever, if you only have a small file with just one or a few lines, you can do so without creating a jinja2 template. Here is the little cheat: Just use ansible’s copy module. – copy:   content: “env: {{ my_environment_var }}”   dest: /app/env.cfg That’s it. This creates a file with variable content, without need to create a template.

  • ansible,  DevOps,  Docker,  Jinja,  Middleware,  YAML

    Ansible Installation auf Windows 10 Systemen

    Ansible kann lokal in der Windows Bash installiert und zusammen mit Visual Studio Code (https://code.visualstudio.com/) effektiv betrieben werden. Die Windows Bash muss installiert sein. Die Bash kann über den Windows Store installiert werden. Einfach nach Ubuntu suchen. Nach der Installation die bash starten. PS C:\Users\user01> bash Die eigentliche ansible Installation erfolgt im Windows Linux Subsystem mit diesen Befehlen. Der letzte Befehl fügt die ansible Kommandos zum Pfad hinzu, damit sie direkt aufrufbar sind. sudo apt-get -y install python-pip python-dev libffi-dev libssl-dev pip install --upgrade pip pip install ansible --user echo 'PATH=$HOME/.local/bin:$PATH' >> ~/.bashrc <em>"pip install --upgrade pip"</em> ist nur der Schönheit halber enthalten, damit pip auch aktuell ist, sonst gibt…