Giter Site home page Giter Site logo

zcode's Introduction

Ansible-Navigator and Builder on RHEL 8.6

https://infohub.delltechnologies.com/l/dell-powermax-ansible-modules-best-practices-1/creating-ansible-execution-environments-using-ansible-builder

  1. python3 -m pip install ansible-navigator --user
  2. echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.profile
  3. source ~/.profile
  4. python3 -m pip install ansible-builder
  5. execution-environment.yml, requirements.yml and requirements.txt

execution-environment.yml

---
version: 1

# build_arg_defaults:
#  EE_BASE_IMAGE: 'quay.io/ansible/ansible-runner:stable-2.10-devel'

#ansible_config: 'ansible.cfg'

dependencies:
  galaxy: requirements.yml
  python: requirements.txt
#  system: bindep.txt

additional_build_steps:
  prepend: |
    RUN whoami
    RUN cat /etc/os-release
  append:
    - RUN echo This is a post-install command!
    - RUN ls -la /etc

requirements.txt

---
jmespath>=1.0.1

requirements.yml

---
collections:
 - name: community.general
 - name: ansible.utils
 - name: awx.awx
 - name: ibm.ibm_zos_core
  1. ansible-builder build <<< will take some time to build.
[sunil390@sunil390 playbooks]$ ansible-builder build
Running command:
 podman build -f context/Containerfile -t ansible-execution-env:latest context
Complete! The build context can be found at: /home/sunil390/playbooks/context
  1. podman images
[sunil390@sunil390 context]$ podman images
REPOSITORY                                 TAG         IMAGE ID      CREATED         SIZE
localhost/ansible-execution-env            latest      b51d4637a6ca  19 minutes ago  1.04 GB
<none>                                     <none>      e126e4efd608  31 minutes ago  1.02 GB
<none>                                     <none>      8db440aa8822  43 minutes ago  816 MB
quay.io/ansible/ansible-runner             latest      bec0dc171168  6 months ago    816 MB
quay.io/ansible/ansible-builder            latest      b0348faa7f41  8 months ago    779 MB
quay.io/ansible/ansible-navigator-demo-ee  0.6.0       e65e4777caa3  15 months ago   1.35 GB

RHEL 8.6 Preparation.

  1. sudo dnf update
  2. sudo yum install python39
  3. sudo python3.9 -m pip install --upgrade pip
  4. sudo python3.9 -m pip install ansible
  5. sudo pip3.9 install jmespath
  6. Update .bashrc
nano .bashrc
alias python3='python3.9'

Jinja2 Templates

  1. Variable {{ variable_name }}
    - name: template task
      template:
        src: index.html.j2
        dest: /var/www/html/index.html
        mode: u=rw,g=r,o=r
  1. Controlling flow : condition checking with % .... %
  server_name _;

        {% if status_url is defined -%}
        location /{{ status_url }} {
            stub_status on;
        }
        {%- endif %}
  1. Loops:
{% for ip in ansible_all_ipv4_addresses %}
    {{ ip }}<br />
{% endfor %}
  1. Whitespace control: Do not indent jinja statements
<div>
{% if say_hello %}
    Hello, world
{% endif %}
</div>
  1. filters: filters only apply to that instance of the variable. 5.1 Jija trim filter will remove the \n from the "from_yaml" filter. 5.2 to_json(indent=8) will make the output file readable.

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.