lebe-dev / ansible-examples-script

Fetch examples for ansible modules into console

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ansible Example Script

Fetch module examples.

Usage

$ ae systemd


  ## Examples

    - name: Make sure a service unit is running
      ansible.builtin.systemd:
        state: started
        name: httpd

    - name: Stop service cron on debian, if running
      ansible.builtin.systemd:
        name: cron
        state: stopped

    - name: Restart service cron on centos, in all cases, also issue daemon-reload to pick up
  config changes
      ansible.builtin.systemd:
        state: restarted
        daemon_reload: yes
        name: crond

    - name: Reload service httpd, in all cases
      ansible.builtin.systemd:
        name: httpd.service
        state: reloaded

Installation

  1. Install html-xml-utils and glow:
paru -S html-xml-utils
sudo pacman -S glow
  1. Install html2md: Use bundled html2md or build from sources (rust required):
git clone https://gitlab.com/Kanedias/html2md.git
cargo build --release
  1. Install ansible example script:

Copy ae.sh in ~/bin and append this path to $PATH.

sudo cp html2md /usr/local/bin/

Create alias in ~/.bashrc:

alias ae="~/bin/ae.sh"

How it works

  1. Check if module page present in file cache
  2. If not present - download into file
  3. Read html, normalize code, select 'Examples' section
  4. Convert html to markdown and create file cache
  5. Render markdown with glow

Thanks

About

Fetch examples for ansible modules into console


Languages

Language:Shell 100.0%