[SOFTWARE] Portable-Ansible on Pandora (instructions)


FBnil

They'll own everything and be miserable.
Joined
Dec 14, 2012
Messages
5,114
Location
Yurp
We have Python on the Pandora, that means that we can run Ansible on top of it.

You can grab the PND from the repo: http://repo.openpandora.org/?page=detail&app=ansible
2019-10-10 Version: 2.8.5.1 : First upload to the Repo.
2019-11-17 Version: 2.9.0.0 Upgraded Ansible from 2.8.5 to 2.9.0
2019-11-17 Version: 2.9.0.1 Rebuild with precompiled pyc files (Ansible now faster, but still slow)
2019-11-22 Version: 2.9.1.1 Never stick with a dot-Oh release.

At initial run it will create a work/ directory with a .bashrc , ansible.cfg, hosts files which you can tailor to your own needs.
Knowledge of Ansible is required, so

Howto (ansible 2.8.5; not using the PND but directly download from the source website):

https://github.com/ownport/portable-ansible

Enable the Pandora's wifi or enable the network.
Go to a fresh new directory on your SD card and from there:

Code:
wget https://github.com/ownport/portable-ansible/releases/download/v0.3.2/portable-ansible-v0.3.2-py2.tar.bz2 -O ansible.tar.bz2
tar xvf ansible.tar.bz2

for l in config console doc galaxy inventory playbook pull vault;do
ln -s ansible ansible-$l
done

After a while (many files to unpack) it will create a subdirectory called ansible (64MB) and a few symlinks that change the behavior.

Now time to test it (takes a while to load and return with an answer):
Code:
python ansible localhost -m ping
python ansible-galaxy search java
python ansible-playbook
python ansible localhost -m setup |head


Next is the configuration file, ansible.cfg

Code:
[defaults]
deprecation_warnings=False
inventory=/your/path/to/ansible/hosts

This overrides the default host list location (/etc/ansible/hosts) to something you can write.
and now you can create a hosts file, with, for example (assuming you have a few virtual machines with those IP addresses):

Code:
[web]
192.168.1.[2:5]
note: unable to connect to remote machines (probably need new ssh) → unfixed

Not sure what you can do with it on a Pandora. It is slow (but not by much compared to a dedicated system), but it works :)
If there is interest, I could make a pnd.

ansible_on_Pandora.jpg



Update: A newer version is available now (v2.8.5): https://github.com/ownport/portable...ad/v0.3.2/portable-ansible-v0.3.2-py2.tar.bz2

If you only have a Windows 10 machine and want to give Ansible a spin: https://www.jeffgeerling.com/blog/2017/using-ansible-through-windows-10s-subsystem-linux


So let's talk about speed: the command "ansible --version" takes 15 seconds. And strangely enough, the PND is 0.05 second faster. (but takes up 10MB more for opening a PND).
 
Last edited:
Hi all :)

@FBnil : nice ! Trying Ansible on the Pandora has been on my TODO list for a long time now (using it on a daily basis at work, nice piece of software IMHO). My plan would be to write Ansible roles for each of my few PNDs and push them to my GitLab repo, that would automate things nicely I guess. I'll give it a try ASAP. On a side note, are there any benefits from using that portable version over the "regular" one which should come with "pip install" in @ptitSeb Code::Blocks ?

Cheers, Magic Sam
 
@Magic Sam Thanks for trying it out. Well, if you "pip install ansible" I guess you will get 2.8.5 (released a month ago) and the other one is stuck in 2.8.0 and probably will not be updated anymore for Python 2.7 (which will get out of support by 2020).
Otoh, when installing, say, new roles, you can use ansible-galaxy and you will get the latest-greatest on both platforms.

The Code::Blocks (all hail ptitSeb) already has Python3 and that python is more compatible with the current Ansible code. (but the strategy is that 2 still stays supported)
We'll have to do a benchmark to test if Python2.7 is faster than Python3 when running Ansible. My gut feeling says that Python3 is slower, but would you notice? Probably not (unless you got huuuge playbooks ;) ).
 
Because Portable-Ansible was updated to 2.8.5, I thought it would be interesting to have a recent Ansible on the Pandora, so here is Portable-Ansible:

It runs on the default Python that the Pandora OS has.


Bugs so far:
  • ansible.cfg should not have any quotes (but can be a relative path). Typo can be fixed → fixed
  • ssh does not have the -C option, and installing "opkg install openssh-sshd" conflicts with Dropbear: Unable to manage remote machines → unfixed
  • Need to remove the "local" in the hosts file for "ansible localhost -m ping" to work again. → fixed
  • Icon missing in Terminal (need to add -I icon.png) → fixed

The command $ time ansible localhost -m setup takes 41 seconds

A new build is coming, but I will play around a few hours and see if I find more.

New build is put up in the repo (2.8.5.1).
 
Last edited:
@Magic Sam I put the new 2.9.0 in the Repo. I tried Python3 from codeblocks but I did not manage to make it run (for that speed comparison I wanted to test). Did you had any luck?

I also thought I had this orageclock.rc all figured out (change the time/date on the taskbar using Ansible), but alas, I am not able to make XFCE4 read the rc from the commandline :(

Code:
- name: Setup my orageclock
  hosts: localhost
  remote_user: ansible
  become: false

  tasks:
    - debug: msg="{{ lookup('env','REAL_HOME') or lookup('env','HOME') }} is your home environment variable"
    - name: Find orageclock
      find:
        paths: "{{ lookup('env','REAL_HOME') or lookup('env','HOME') }}/Applications/Settings/xfce4/panel"
        patterns: 'orageclock-*.rc'
      register: files_to_modify
    - debug: msg="{{ files_to_modify.matched }} files found."
    - name: show file found
      debug: msg="{{ files_to_modify.files[0].path|quote }}"
#      when: files_to_modify.matched > 0
    - name:
      ini_file:
        path: "{{ files_to_modify.files[0].path }}"
        section: null
        option: "{{ item.key }}"
        value: "{{ item.val }}"
        backup: no
        allow_no_value: yes
        no_extra_spaces: yes
      loop:
        - { key: 'show_frame', val: 'false'}
        - { key: 'font0', val: 'Monospace 11'}
        - { key: 'show0', val: 'true'}
        - { key: 'data0', val: '%a %R'}
        - { key: 'font1', val: 'Sans 9'}
        - { key: 'show1', val: 'true'}
        - { key: 'data1', val: '%V %Y-%m-%d'}
#        - { key: '', val: ''}
#        - { key: '', val: ''}
#      when: files_to_modify.matched
      register: inihasbeen
    - name: restart XFCE4
      command: "xfce4-panel -r"
      when: inihasbeen.changed
 
Back
Top