Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing IP address/restarting netplan

Tags:

ansible

I have a very simple ansible playbook that replaces the /etc/netplan/config.yml.

and then restarts netplan.

The issue is that when restarting netplan the IP address changes, so ansible hangs indeffinatly.

How can i avoid this? I want to just run the command and not wait for a response, or run a command and then test on the new IP.

I can't find anything in the documentation,

Its a very simple role -

task/main.yml
- name: Updating Network Configuration
  template: src=config.yml dest=/etc/netplan/config.yaml
  notify: start netplan


handlers/main.yml
- name: start netplan
  shell: netplan apply

I'd like to add, just tried this..which should fire/forget but it still hangs

- name: start netplan
  shell: netplan apply
  async: 1
  poll: 0
like image 894
TheOne745665 Avatar asked Mar 10 '26 20:03

TheOne745665


1 Answers

I had exactly the same issue and async worked fine for me :

- name: Apply netplan
  command: sudo netplan apply
  async: 45
  poll: 0
like image 136
overflowed Avatar answered Mar 12 '26 16:03

overflowed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!