vmware / photon

Minimal Linux container host
https://vmware.github.io/photon
Other
3.05k stars 696 forks source link

Ansible & tdnf #1245

Open whitehat101 opened 3 years ago

whitehat101 commented 3 years ago

I'm trying to learn Ansible to manage my Photon VMs on ESXi. I was expecting a playbook like this would work from inside a PhotonOS 4.0 Docker image:

---
- hosts: k8s-server
  tasks:
  - name: Install K8s
    tdnf:
      name: kubernetes,iptables
      state: latest
      update_cache: yes

But I get errors: ERROR! couldn't resolve module/action 'tdnf'. This often indicates a misspelling, missing collection, or incorrect module path.

I see this patch: https://github.com/vmware/photon/blob/master/SPECS/ansible/ansible.spec & https://github.com/vmware/photon/blob/master/SPECS/ansible/ansible-tdnf.patch Which appears to add the tdnf module to Ansible, but I haven't been able to figure out how to get that patched version of Ansible. The version in the Docker image is:

# ansible --version
ansible 2.9.22
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.9.1 (default, Aug 19 2021, 02:58:42) [GCC 10.2.0]

I started trying to learn rpmbuild to build that spec, but I've encountered various issues, most recently that ansible-2.11.1 doesn't actually seem to be released http://releases.ansible.com/ansible/ansible-2.11.1.tar.gz https://pypi.org/project/ansible/#history

Is there a supported way to get Ansible with tfnd, on any OS? Perhaps a YUM repo I need to add? Or a command in this repo that I should be running that will successfully build that spec?

dcasota commented 3 years ago

Hi, you may have a look to @Texiwill' aac-lib, see https://github.com/Texiwill/aac-lib/blob/master/base/ansible/aac-base-tz.yaml. He solved some issues using dependency checks 'ansible_os_family == "VMware Photon OS"' and 'ansible_os_family != "VMware Photon OS"'.

whitehat101 commented 3 years ago

I eventually just applied the patch manually in my Dockerfile:

FROM photon:4.0
RUN tdnf update
RUN tdnf install -y ansible openssh-clients sshpass

# Add the Ansible tdnf module
WORKDIR /usr/share/ansible/plugins/modules
RUN curl https://raw.githubusercontent.com/vmware/photon/master/SPECS/ansible/ansible-tdnf.patch | patch

WORKDIR /root

And that worked for me.

I still feel like I'm overlooking the intended way to use that patch.