nixos/cloud-init: order after network-online.target (#44633)

Some modules of cloud-init can cope with a network not immediately
available (notably, the EC2 module), but some others won't retry if
network is not available (notably, the Cloudstack module).
network.target doesn't give much guarantee about the network
availability. Applications not able to start without a fully
configured network should be ordered after network-online.target.

Also see #44573 and #44524.

authored by

Vincent Bernat and committed by
xeji
57840dbf b35238f9

+7 -6
+7 -6
nixos/modules/services/system/cloud-init.nix
··· 104 104 systemd.services.cloud-init = 105 105 { description = "Initial cloud-init job (metadata service crawler)"; 106 106 wantedBy = [ "multi-user.target" ]; 107 - wants = [ "local-fs.target" "cloud-init-local.service" "sshd.service" "sshd-keygen.service" ]; 108 - after = [ "local-fs.target" "network.target" "cloud-init-local.service" ]; 107 + wants = [ "local-fs.target" "network-online.target" "cloud-init-local.service" 108 + "sshd.service" "sshd-keygen.service" ]; 109 + after = [ "local-fs.target" "network-online.target" "cloud-init-local.service" ]; 109 110 before = [ "sshd.service" "sshd-keygen.service" ]; 110 111 requires = [ "network.target "]; 111 112 path = path; ··· 121 122 systemd.services.cloud-config = 122 123 { description = "Apply the settings specified in cloud-config"; 123 124 wantedBy = [ "multi-user.target" ]; 124 - wants = [ "network.target" ]; 125 - after = [ "network.target" "syslog.target" "cloud-config.target" ]; 125 + wants = [ "network-online.target" ]; 126 + after = [ "network-online.target" "syslog.target" "cloud-config.target" ]; 126 127 127 128 path = path; 128 129 serviceConfig = ··· 137 138 systemd.services.cloud-final = 138 139 { description = "Execute cloud user/final scripts"; 139 140 wantedBy = [ "multi-user.target" ]; 140 - wants = [ "network.target" ]; 141 - after = [ "network.target" "syslog.target" "cloud-config.service" "rc-local.service" ]; 141 + wants = [ "network-online.target" ]; 142 + after = [ "network-online.target" "syslog.target" "cloud-config.service" "rc-local.service" ]; 142 143 requires = [ "cloud-config.target" ]; 143 144 path = path; 144 145 serviceConfig =