Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[networking] allow for static IP assignment in spinup.sh #37

Open
leifmadsen opened this issue May 1, 2018 · 1 comment
Open

[networking] allow for static IP assignment in spinup.sh #37

leifmadsen opened this issue May 1, 2018 · 1 comment

Comments

@leifmadsen
Copy link
Contributor

I have a lab situation where it would be really nice if I could just assign a static_ip value to the inventory items.

I've prototyped out some cloud-init stuff, and it seems to work. I need to add it all to Ansible and provide something that can be done dynamically.

@leifmadsen
Copy link
Contributor Author

Raw POC (nothing dynamic here):

@@ -1,8 +1,8 @@
 #!/bin/bash
 
 # Take one argument from the commandline: VM name
-if [ $# -gt 3 ] || [ $# -lt 1 ]; then
-    echo "Usage: $0 <node-name> {memory-MB} {vCPUs}"
+if [ $# -gt 4 ] || [ $# -lt 1 ]; then
+    echo "Usage: $0 <node-name> {memory-MB} {vCPUs} {IP-address}"
     exit 1
 fi
 
@@ -94,7 +94,18 @@
   - {{ vm_ssh_key }}
 _EOF_
 
-    echo "instance-id: $1; local-hostname: $1" > $META_DATA
+    cat > $META_DATA << _EOF_
+instance-id: $1
+local-hostname: $1
+network-interfaces: |
+  auto eth0
+  iface eth0 inet static
+    address $4
+    network 192.168.3.0
+    netmask 255.255.255.0
+    broadcast 192.168.3.255
+    gateway 192.168.3.1
+_EOF_
 
     echo "$(date -R) Copying template image..."
     cp $IMAGE $DISK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant