How to define "ANSIBLE_PYTHON_INTERPRETER" in docker-compose.yml

I’m having second thoughts asking this question here, since it might be a semaphore question, not ansible, but semaphore is a great way of getting started with ansible so I’m taking my chances.

This is how I installed semaphore with ansible.

services:
  mariadb:
    image: linuxserver/mariadb
    container_name: mariadb
    hostname: mariadb
    restart: unless-stopped
    environment:
      - PUID=1001
      - PGID=1001
      - MYSQL_USER=semaphore
      - MYSQL_PASSWORD=semaphore
      - MYSQL_DATABASE=semaphore
      - MYSQL_ROOT_PASSWORD=root_pass_here
    ports:
      - 3306:3306
    volumes:
      - mariadb:/config

  semaphore:
    image: semaphoreui/semaphore
    container_name: semaphore
    hostname: semaphore
    restart: unless-stopped
    environment:
      - PUID=1001
      - PGID=1001

      - SEMAPHORE_DB=semaphore
      - SEMAPHORE_DB_USER=semaphore
      - SEMAPHORE_DB_PASS=semaphore

      - SEMAPHORE_DB_PORT=3306
      - SEMAPHORE_DB_HOST=mariadb
      - SEMAPHORE_DB_DIALECT=mysql
      - SEMAPHORE_PLAYBOOK_PATH=/tmp/semaphore/

      - SEMAPHORE_ADMIN=admin
      - SEMAPHORE_ADMIN_NAME=admin
      - SEMAPHORE_ADMIN_PASSWORD=admin
      - SEMAPHORE_ADMIN_EMAIL=admin@localhost
      - SEMAPHORE_ACCESS_KEY_ENCRYPTION=key_here

      - ANSIBLE_HOST_KEY_CHECKING=false
      - ANSIBLE_PYTHON_INTERPRETER=auto_silent
    ports:
      - 3000:3000
    volumes:
      - semaphore:/etc/ansible
      - semaphore:/etc/semaphore
      - semaphore:/tmp/semaphore
      - semaphore:/var/lib/semaphore

volumes:
  mariadb:
  semaphore:

If I check ansible.cfg the variable ANSIBLE_HOST_KEY_CHECKING=false appears to be there.

[defaults]
host_key_checking = False
bin_ansible_callbacks = True
stdout_callback = yaml

But the variable ANSIBLE_PYTHON_INTERPRETER=auto_silent seems to be ignored. It doesn’t exist in ansible.cfg

As a result, all my tasks produce the same warning.

I know I can define this manually in ansible.cfg, but I would really prefer to do it in docker-compose.yml

1 Like

Creating the environment variable should not update ansible.cfg, it overrides it. In any case the issue here is that you are assuming semaphore passes it’s full environment to ansible CLI

1 Like