0

so I have a couple raspberry pi's I'm trying to use as a cluster and I'm learning ansible to try and manage them easier. I'm running into an issue though. I can manually set the IP static using netctl but when I try to do it with ansible using the same exact commands I have issues. Also a weird note, the version that doesnt work, doesnt work on raspberry pi 4's but will work on raspberry pi b's.

For example if I use the following (enter it in manually) I get no issues what so ever:

/etc/netctl/eth0

Description='Static IP for cluster'
Interface=eth0
Connection=ethernet
IP=static
Address=('192.168.1.173/24')
#Routes=('192.168.0.0/24 via 192.168.1.2')
Gateway='192.168.1.1'
DNS=('192.168.1.1')

netctl enable eth0

systemctl stop dhcpcd

systemctl stop dhcpcd

and after reboot it works fine.

I can also get it to work if I use the following:

- name: copy static IP file
  block:
    - name: create netctl file
      raw: echo $'Description=\'A basic static ethernet connection\'\nInterface=eth0\nConnection=ethernet\nIP=static\nAddress=(\'{{ host_ip_addr }}/24\')\n#Routes=(\'192.168.0.0/24 via 192.168.1.2\')\nGateway=\'192.168.1.1\'\nDNS=(\'192.168.1.1\')' > /etc/netctl/eth0
      args:
        executable: /bin/bash  
    - name: chmod netctl file
      raw: chmod 644 /etc/netctl/eth0
      args:
        executable: /bin/bash 
 
- name: start and enable netctl
  block:
    - name: enable eth0 in netctl
      raw: netctl enable eth0
      args:
        executable: /bin/bash 
      register: net    
    - name: stop dhcpcd 
      raw: systemctl stop dhcpcd;
      args:
        executable: /bin/bash 
      register: net2
    - name: disable dhcpcd 
      raw: systemctl disable dhcpcd;
      args:
        executable: /bin/bash
      register: net3  

But it fails to work if I use:

- name: setup static IP
  template:
    src: staticIP-netctl.j2
    dest: /etc/netctl/eth0
    owner: root 
    group: root
    mode: 0644

- name: start and enable netctl
  block:
    - name: enable eth0 in netctl
      service: 
        name: netctl
        state: started
        enabled: yes  
    - name: stop and disable dhcpcd (dynamic IP addresses)
      service: 
        name: dhcpcd
        state: stopped
        enabled: no      

or this also fails

- name: setup static IP
  template:
    src: staticIP-netctl.j2
    dest: /etc/netctl/eth0
    owner: root 
    group: root
    mode: 0644

- name: start and enable netctl
  block:
    - name: enable eth0 in netctl
      raw: netctl enable eth0
      args:
        executable: /bin/bash   
    - name: stop and disable dhcpcd (dynamic IP addresses)
      raw: systemctl stop dhcpcd
      args:
        executable: /bin/bash      
    - name: stop and disable dhcpcd 2 (dynamic IP addresses)
      raw: systemctl disable dhcpcd
      args:
        executable: /bin/bash 

my staticIP-netctl.j2 file is:

Description='A basic static ethernet connection'
Interface=eth0
Connection=ethernet
IP=static
Address=('{{ host_ip_addr }}/24')
#Routes=('192.168.0.0/24 via 192.168.1.2')
Gateway='192.168.1.1'
DNS=('192.168.1.1')

and it's in the roles/role/templates folder, it's also being copied over correctly as I have checked manually on each pi.

Any ideas why this may be happening?


EDIT-SOLUTION:

Turns out it was a kernel issue (linux-aarch64), after updating all packages on a fresh install the kernel no longer recognized any of my network interfaces. You can switch to linux-raspberrypi4 or downgrade to linux-aarch64 5.11.x anything pre mid-September (http://tardis.tiny-vps.com/aarm/repos/2021/06/13/aarch64/core/).

  • 1
    What you you mean by fails? Edit your question to add any errors from Ansible, the resulting config file on the host, and the state of networking from ip commands. – John Mahowald Nov 01 '21 at 14:02
  • 1
    Sorry your right i wasn't very clear but I wasn't sure what was going on. I broke the playbook out into separate commands and it turned out that after a full system update I no longer had an internet connection, but I figured it out. – user1884295 Nov 02 '21 at 16:15

0 Answers0