Skip to content

Commit

Permalink
Issue #10: Make playbook work well on Ubuntu hosts.
Browse files Browse the repository at this point in the history
  • Loading branch information
geerlingguy committed Apr 23, 2024
1 parent 23850f7 commit b8544ff
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ ansible-playbook networking.yml

After running the playbook, until a reboot, the Pis will still be accessible over their former DHCP-assigned IP address. After rebooting, the nodes will be accessible on their new IP addresses.

You can reboot all the nodes with:

```
ansible all -m reboot -b
```

> If you are running Ubuntu, and you get an error like `"Failed to find required executable "nmcli"`, run the `ubuntu-setup.yml` playbook: `ansible-playbook tasks/networking/ubuntu-prep.yml`
#### If using a different subnet

If you chose a different subnet than your LAN, make sure your workstation is connected to an interface on the same subnet as the cluster (e.g. `10.1.1.x`).
Expand Down
2 changes: 2 additions & 0 deletions example.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ drupal_extra_settings_php: ''
# remote networking features in the `tasks/networking` playbooks.
ipv4_subnet_prefix: "10.1.1"
ipv4_gateway: "10.1.1.1"
dns4_servers: "{{ ipv4_gateway }}"
active_internet_interface: "wlan0"
reverse_tunnel_enable: false
reverse_tunnel_vps_username: my-vps-username
reverse_tunnel_vps_hostname: my-vps-hostname
control_plane_router_setup: false
1 change: 1 addition & 0 deletions networking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@

- name: Configure control plane as a router.
import_playbook: tasks/networking/router.yml
when: control_plane_router_setup
1 change: 1 addition & 0 deletions tasks/networking/static-networking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
type: ethernet
ip4: "{{ ipv4_subnet_prefix }}.{{ ip_host_octet }}/24"
gw4: "{{ ipv4_gateway }}"
dns4: "{{ dns4_servers }}"
state: present
notify: restart networkmanager
when: not dhcpcd_file_result.stat.exists
Expand Down
34 changes: 34 additions & 0 deletions tasks/networking/ubuntu-prep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
- name: Prepare Ubuntu for static networking.
hosts: cluster
gather_facts: false
become: true

vars:
netplan_file: /etc/netplan/50-cloud-init.yaml

tasks:
- name: Ensure NetworkManager is installed.
ansible.builtin.apt:
name: network-manager
state: present
update_cache: true

- name: Configure netplan file for NetworkManager.
ansible.builtin.copy:
dest: "{{ netplan_file }}"
mode: 0600
content: |
# ANSIBLE MANAGED - netplan configuration
network:
version: 2
renderer: NetworkManager
- name: Regenerate netplan config.
ansible.builtin.command: "{{ item }}"
with_items:
- sudo netplan generate
- sudo netplan apply

- name: Reboot.
ansible.builtin.reboot:
2 changes: 1 addition & 1 deletion tasks/storage/filesystem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ansible.builtin.file:
dest: "/{{ storage_nfs_dir }}/{{ storage_nfs_share_name }}"
owner: root
group: pi
group: "{{ ansible_user }}"
state: directory
mode: 0777

Expand Down

0 comments on commit b8544ff

Please sign in to comment.