Ajitabh Pandey's Soul & Syntax

Exploring systems, souls, and stories – one post at a time

Tag: ansible

  • Get Oracle XE-ORDS-APEX Up and Running Quickly with Ansible

    Oracle APEX is a rapid application development tool and from what I have seen its quite powerful. Clubed together with ORDS, it is a powerful tool to develop enterprise applications which are highly scalable, provided you are willing to spend $$$$ as everything depends on underlying Oracle Database.

    For those who want to learn the tool, Oracle XE (Express Edition) can be used as a development environment. Setting up the full stack can be a little bit challenging for developers who wants to stick to building their core strength and not mess with infrastructure deployments etc.

    To help here, I wrote this ansible playbook, which will quickly setup the entire stack. Accompanied in the git repository are the Vagrantfile which can quickly setup the DEV environment in a VirtualBox VM. The stack is currently based on CentOS 7.x (and can run in RHEL 7.x as well).

    The README file in the git repostory is self explanatory and explains in detail on how to use this playbook to get the stack up and running.

    Upcoming Enhancements

    I will be making suitable modifications in to make it run on RHEL 8.x and Oracle Linux 8.x. I will also be working on fixing the accompanied packer file which has not been tested thoroughly for building a Docker Image. I plan to get a packer file in place to build a VirtualBox box file, a Digital Ocean droplet image, and a Docker build.

    Keep watching the GitHub repository for the changes and do report any issues or feature enhancements. Feel free to submit PRs in case you get to the planned enhancements before me.

  • Ansible Quirks – 4

    I was installing ansible on OpenSuSE Leap 42.3 machine and faced a problem with multiple python versions. I have both python 2.7 and python 3.4 installed on this machine. Python 2.7 is the default one.

    I tried installed ansible with the usual pip install and was faced with an error related to setuptools (could not capture the error message). I upgraded my pip version to the latest one 10.0.1 and then installed ansible.

    $ sudo pip install --upgrade pip
    $ sudo pip install ansible

    After that I ran an ansible-galaxy init command to create one of the roles and I was welcome with the error stating “Error: Ansible requires a minimum of Python2 version 2.6 or Python3 version 3.5. Current version: 3.4.6”. And I was wondering what happened because my default python version was 2.7.

    The usual google search did not help me go anywhere. So I looked at the /usr/bin/ansible file and found that it was using python3 interpreter.

    $ head -1 /usr/bin/ansible
    #!/usr/bin/python3

    I then checked the source of pip command and found the same thing.

    $ head -1 /usr/bin/pip
    #!/usr/bin/python3

    So I looked at pip documentation on installing pip for python 2.7 and found this link which helped me with the command to install pip for the default version of python installed –

    $ sudo python -m ensurepip --default-pip
    Requirement already satisfied: setuptools in /usr/lib/python2.7/site-packages
    Collecting pip
    Installing collected packages: pip
    Successfully installed pip-9.0.1

    Now when I reinstalled ansible, it installed the correct python interpreter for my system.

    $ sudo pip install ansible
    Collecting ansible
      Cache entry deserialization failed, entry ignored
    .....
    .....
    You are using pip version 9.0.1, however version 10.0.1 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.
    $ head -1 /usr/bin/pip /usr/bin/ansible
    ==> /usr/bin/pip <==
    #!/usr/bin/python
    
    ==> /usr/bin/ansible <==
    #!/usr/bin/python

    Now when I upgraded pip it was for the default python version

    $ sudo pip install --upgrade pip
    Collecting pip
    Using cached https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl
    Installing collected packages: pip
    Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
        Successfully uninstalled pip-9.0.1
        Successfully installed pip-10.0.1
    $ head -1 /usr/bin/pip /usr/bin/ansible
    ==> /usr/bin/pip  <==
    #!/usr/bin/python
    
    ==> /usr/bin/ansible <==
    #!/usr/bin/python</p>

    In all probability all this was my fault and I think the pip which I upgraded in the beginning of this process may have been installed for python3 by me, otherwise I do not see any reason for all these issues.

    Still I thought to share this entry, just in case someone can be helped.

     

  • Ansible Quirks – 3

    I was running some playbook today and realise that the command line arguments of ansible-playbook do not behaves expected.

    My playbook has the following defined –

    remote_user: root

    When I issued the following command, my expectation was that the remote user name would be considered as specified by the “-u” option

    $ ansible-playbook -u centos -i '192.168.1.192,' play.yml

    However, this does not happen and the playbook still tries to connect as the user defined in the yml file.

    So, how do we override what is in the yml file through command line. The only way seems to be possible is using the -e or --extra-vars option as follows –

    $ ansible-playbook -e "ansible_ssh_user=centos ansible_ssh_private_key_file=~/.ssh/db_hosts_id_rsa " -i '192.168.1.192,' play.yml

  • Ansible Quirks – 2

    Today I tried to upgrade my ansible to 2.2 as I wanted to use the remote_src=yes feature from the unarchive module. My operating system on this machine is Linux Mint 17.3.

    I did –

    $ pip install --upgrade --user ansible

    and lo… I got the following error –

    ImportError: No module named packaging.version

    I next tried upgrading the pip itself and that also resulted in the same error. A bit of search on the internet did not help much as different ways worked for different people. So I decided to remove python-pip package and all that was installed along with it, reinstall pip and then try upgrading ansible. In short, following sequence of commands worked for me –

    
    $ rm -rf ~/.cache/pip/*
    $ python -m pip install -U --user pip
    $ sudo apt-get purge -y python-pip
    $ sudo apt-get autoremove
    $ sudo apt-get install python-dev
    $ python -m pip install --upgrade --user packaging
    $ python -m pip install --upgrade --user appdirs
    $ python -m pip install --upgrade --user ansible
    
  • Ansible Quirks – 1

    I started on the ansible learning path about 6 months or so back and have been writing my roles for deploying / configuring various systems I manage. Today while writing a template for sshd_config, I came across a point wherein the handler failed to restart the SSH service on the target server. Fortunately I was logged in as sudo on one of the terminals, and then I checked the config file generated and pushed by ansible. I found that the line

    PermitRootLogin {{ permit_root_login }}

    was translated to

    PermitRootLogin True

    . For a while I though that the variable I defined in

    defaults/main.yml

    was wrongly having a value of True instead of Yes, but I was wrong. Looking into some of the bugs filed in ansible I realised that this is the expected behaviour. The way to prevent strings like yes/no and true/false to be converted to True/False they have to be preceded with !!str in the variable definition. So the variable definition in my case would look like –

    permit_root_login: !!str Yes