Score:0

How to assign a static IP with molecule-podman?

br flag

As the generated inventory look like a pair of instance name - ip (see above), I need to test recipe using the variable ansible_host with an IP value and not the instance name.

So the generated inventory look like:

[all]
idm ansible_host=10.0.1.1
client1 ansible_host=10.0.1.2
[client]
client1 ansible_host=10.0.1.2

Thus the molecule.yml contains:

platforms:
  - name: idm
    image: quay.io/freeipa/freeipa-server:rocky-8-4.9.6
    pre_build_image: true
    privileged: false
    network: testing
    hostname: idm.org.test
    command: ipa-server-install -U --realm=ORG.TEST --domain=org.test --ds-password=IsASecret --admin-password=IsASecret --hostname=idm.org.test

  - name: client1
    image: quay.io/rockylinux/rockylinux
    pre_build_image: true
    privileged: false
    network: testing
    hostname: client1.org.test
    groups:
      - all
      - client

Following this configuration I am able to put into the same network these 2 instances but I can not assign a static IP to them. Moreover here, ansible_host take the instance name as value (idm, client1).

Note: as it is wrote in title I use molecule-podman to create instances and test

Thanks for your help

Best regards

Score:0
sy flag

If you need static IP (you could use dns BTW but you probably already know that since your client seem to use idm.org.test) I think that you have to use your own create.yml file based on https://github.com/ansible-community/molecule-podman/blob/main/src/molecule_podman/playbooks/create.yml to do such a thing.

Because my understanding is that you can not control lots of parameter when the network is created by podman.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.