From 18530070716f2a174f426bbed974ec04a76e944d Mon Sep 17 00:00:00 2001 From: Adam Schaub Date: Thu, 13 Oct 2016 22:42:02 -0400 Subject: [PATCH 1/7] Model refactor idea --- assets/ignition/etcd.yaml | 32 ++++---------------- sites/test-site/env.yml | 30 ++++++++++++++++++ sites/test-site/groups.yml | 23 ++++++++++++++ sites/test-site/hosts/clevos.yml | 10 ++++++ sites/test-site/hosts/etcd-masters.yml | 29 ++++++++++++++++++ sites/test-site/hosts/etcd-proxy.yml | 20 ++++++++++++ sites/test-site/inventory.yml | 42 -------------------------- 7 files changed, 118 insertions(+), 68 deletions(-) create mode 100644 sites/test-site/groups.yml create mode 100644 sites/test-site/hosts/clevos.yml create mode 100644 sites/test-site/hosts/etcd-masters.yml create mode 100644 sites/test-site/hosts/etcd-proxy.yml delete mode 100644 sites/test-site/inventory.yml diff --git a/assets/ignition/etcd.yaml b/assets/ignition/etcd.yaml index c751a0b..9ce6b0f 100644 --- a/assets/ignition/etcd.yaml +++ b/assets/ignition/etcd.yaml @@ -1,36 +1,16 @@ --- -systemd: - units: - - name: etcd2.service - enable: true - dropins: - - name: 40-etcd-cluster.conf - contents: | - [Service] - Environment="ETCD_NAME={{.host.etcd_name}}" - Environment="ETCD_ADVERTISE_CLIENT_URLS=http://{{.host.ipv4_address}}:2379" - Environment="ETCD_INITIAL_ADVERTISE_PEER_URLS=http://{{.host.ipv4_address}}:2380" - Environment="ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379" - Environment="ETCD_LISTEN_PEER_URLS=http://{{.host.ipv4_address}}:2380" - Environment="ETCD_INITIAL_CLUSTER={{.env.etcd_initial_cluster}}" - Environment="ETCD_STRICT_RECONFIG_CHECK=true" - - name: fleet.service - enable: true - dropins: - - name: fleet-metadata.conf - contents: | - [Service] - Environment="FLEET_METADATA=role={{.group.fleet_role}},name={{.host.etcd_name}}" networkd: units: + {{ with index .host.interfaces 0}} - name: 10-static.network contents: | [Match] - MACAddress={{.host.mac}} + MACAddress={{.mac}} [Network] - Gateway={{.env.networkd_gateway}} - DNS={{.env.networkd_dns}} - Address={{.host.networkd_address}} + Gateway={{.subnet.gateway}} + DNS={{ index .subnet.dns 0 }} + Address={{ .ipv4 }} + {{ end }} {{ if index .env "ssh_authorized_keys" }} passwd: users: diff --git a/sites/test-site/env.yml b/sites/test-site/env.yml index c7fde19..7adda3f 100644 --- a/sites/test-site/env.yml +++ b/sites/test-site/env.yml @@ -1,6 +1,36 @@ --- name: Virtualenv Dev id: test-site +subnets: + - id: default + cidr: 10.10.10.0/24 + domain: foo.bar.com + dns: + - 8.8.8.8 + ntp: + - 10.10.10.1 + - id: clevos + cidr: 192.168.1.0/24 + domain: foo.bar.com + gateway: 192.168.1.1 + dns: + - 8.8.8.8 + - id: mgmt-subnet + cidr: 10.9.9.0/24 + dns: + - 8.8.8.8 + ntp: + - 10.10.10.1 +# Let's eventually replace this +agent: + url: "http://127.0.0.1" + port: 24602 + secure_url: "https://some.proper.domainname.com" + secure_port: 443 + cert_path: /etc/vaquero/certs/test-site.crt +# With this +agent: id-for-agent-on-controller # gain this ID from the registration process + agent: url: "http://127.0.0.1" port: 24602 diff --git a/sites/test-site/groups.yml b/sites/test-site/groups.yml new file mode 100644 index 0000000..e6290c0 --- /dev/null +++ b/sites/test-site/groups.yml @@ -0,0 +1,23 @@ +--- +host_group: etcd-cluster +hosts: +- name: host1 + etcd_name: node1 +- name: host2 + metadata: + etcd_name: node2 +- name: host3 + metadata: + etcd_name: node3 +--- +host_group: etcd-proxy +hosts: + - name: proxy1 + - name: proxy2 +--- +host_group: clevos +hosts: +- name: clevos1 + metadata: + ipv4_address: 192.128.1.16 + clever_name: haha \ No newline at end of file diff --git a/sites/test-site/hosts/clevos.yml b/sites/test-site/hosts/clevos.yml new file mode 100644 index 0000000..d5b8f6b --- /dev/null +++ b/sites/test-site/hosts/clevos.yml @@ -0,0 +1,10 @@ +--- +name: clevos1 +interfaces: + - type: physical + dhcp: yes + subnet: default + mac: 00:00:00:00:00:06 + identifier: eth0 + ipv4: 192.128.1.16 + hostname: proxy1 \ No newline at end of file diff --git a/sites/test-site/hosts/etcd-masters.yml b/sites/test-site/hosts/etcd-masters.yml new file mode 100644 index 0000000..45dba79 --- /dev/null +++ b/sites/test-site/hosts/etcd-masters.yml @@ -0,0 +1,29 @@ +--- +name: host1 +interfaces: + - type: physical # can be physical/bmc/bond/virtual + dhcp: yes + subnet: default + mac: 00:00:00:00:00:01 + identifier: eth0 + ipv4: 10.10.10.10 + hostname: host1 + # could add ipv6 later +--- +name: host2 + - type: physical + dhcp: yes + subnet: default + mac: 00:00:00:00:00:02 + identifier: eth0 + ipv4: 10.10.10.11 + hostname: host2 +--- +name: host3 + - type: physical + dhcp: yes + subnet: default + mac: 00:00:00:00:00:03 + identifier: eth0 + ipv4: 10.10.10.12 + hostname: host3 diff --git a/sites/test-site/hosts/etcd-proxy.yml b/sites/test-site/hosts/etcd-proxy.yml new file mode 100644 index 0000000..dfe1b83 --- /dev/null +++ b/sites/test-site/hosts/etcd-proxy.yml @@ -0,0 +1,20 @@ +--- +name: proxy1 +interfaces: + - type: physical + dhcp: yes + subnet: default + mac: 00:00:00:00:00:04 + identifier: eth0 + ipv4: 10.10.10.13 + hostname: proxy1 +--- +name: proxy2 +interfaces: + - type: physical + dhcp: yes + subnet: default + mac: 00:00:00:00:00:05 + identifier: eth0 + ipv4: 10.10.10.14 + hostname: proxy2 \ No newline at end of file diff --git a/sites/test-site/inventory.yml b/sites/test-site/inventory.yml deleted file mode 100644 index 216bb06..0000000 --- a/sites/test-site/inventory.yml +++ /dev/null @@ -1,42 +0,0 @@ ---- -host_group: etcd-proxy -hosts: -- name: proxy1 - selectors: - mac: 00:00:00:00:00:04 -- name: proxy2 - selectors: - mac: 00:00:00:00:00:05 ---- -host_group: etcd-cluster -hosts: -- name: host1 - selectors: - mac: 00:00:00:00:00:01 - metadata: - ipv4_address: 10.10.10.10 - networkd_address: 10.10.10.10/16 - etcd_name: node1 -- name: host2 - selectors: - mac: 00:00:00:00:00:02 - metadata: - ipv4_address: 10.10.10.11 - networkd_address: 10.10.10.11/16 - etcd_name: node2 -- name: host3 - selectors: - mac: 00:00:00:00:00:03 - metadata: - ipv4_address: 10.10.10.12 - networkd_address: 10.10.10.12/16 - etcd_name: node3 ---- -host_group: clevos -hosts: -- name: clevos1 - selectors: - mac: 00:00:00:00:00:06 - metadata: - ipv4_address: 192.128.1.16 - clever_name: haha \ No newline at end of file From 38ecd06bc456c7030299220862c4f417961ae8d6 Mon Sep 17 00:00:00 2001 From: Adam Schaub Date: Fri, 28 Oct 2016 15:33:38 -0400 Subject: [PATCH 2/7] more hosts --- sites/test-site/env.yml | 8 +------- sites/test-site/groups.yml | 7 +++++-- sites/test-site/hosts/clevos.yml | 2 -- sites/test-site/hosts/etcd-masters.yml | 8 +++++++- sites/test-site/hosts/etcd-proxy.yml | 2 -- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/sites/test-site/env.yml b/sites/test-site/env.yml index 7adda3f..0c6a2ef 100644 --- a/sites/test-site/env.yml +++ b/sites/test-site/env.yml @@ -29,14 +29,8 @@ agent: secure_port: 443 cert_path: /etc/vaquero/certs/test-site.crt # With this -agent: id-for-agent-on-controller # gain this ID from the registration process +#agent: id-for-agent-on-controller # gain this ID from the registration process -agent: - url: "http://127.0.0.1" - port: 24602 - secure_url: "https://some.proper.domainname.com" - secure_port: 443 - cert_path: /etc/vaquero/certs/test-site.crt metadata: name: detroit-preprod kind: pre-prod diff --git a/sites/test-site/groups.yml b/sites/test-site/groups.yml index e6290c0..7c48763 100644 --- a/sites/test-site/groups.yml +++ b/sites/test-site/groups.yml @@ -1,7 +1,10 @@ --- host_group: etcd-cluster +selectors: + rootvol: installed hosts: - name: host1 + metadata: etcd_name: node1 - name: host2 metadata: @@ -12,8 +15,8 @@ hosts: --- host_group: etcd-proxy hosts: - - name: proxy1 - - name: proxy2 +- name: proxy1 +- name: proxy2 --- host_group: clevos hosts: diff --git a/sites/test-site/hosts/clevos.yml b/sites/test-site/hosts/clevos.yml index d5b8f6b..83840b4 100644 --- a/sites/test-site/hosts/clevos.yml +++ b/sites/test-site/hosts/clevos.yml @@ -2,9 +2,7 @@ name: clevos1 interfaces: - type: physical - dhcp: yes subnet: default mac: 00:00:00:00:00:06 - identifier: eth0 ipv4: 192.128.1.16 hostname: proxy1 \ No newline at end of file diff --git a/sites/test-site/hosts/etcd-masters.yml b/sites/test-site/hosts/etcd-masters.yml index 45dba79..94a50c1 100644 --- a/sites/test-site/hosts/etcd-masters.yml +++ b/sites/test-site/hosts/etcd-masters.yml @@ -5,12 +5,17 @@ interfaces: dhcp: yes subnet: default mac: 00:00:00:00:00:01 + bmc: + type: ipmi # ipmi (specifically over LAN)/cimc/etc + username: adam + password: schaub identifier: eth0 ipv4: 10.10.10.10 hostname: host1 - # could add ipv6 later +# could add ipv6 later --- name: host2 +interfaces: - type: physical dhcp: yes subnet: default @@ -20,6 +25,7 @@ name: host2 hostname: host2 --- name: host3 +interfaces: - type: physical dhcp: yes subnet: default diff --git a/sites/test-site/hosts/etcd-proxy.yml b/sites/test-site/hosts/etcd-proxy.yml index dfe1b83..8fe643a 100644 --- a/sites/test-site/hosts/etcd-proxy.yml +++ b/sites/test-site/hosts/etcd-proxy.yml @@ -2,7 +2,6 @@ name: proxy1 interfaces: - type: physical - dhcp: yes subnet: default mac: 00:00:00:00:00:04 identifier: eth0 @@ -12,7 +11,6 @@ interfaces: name: proxy2 interfaces: - type: physical - dhcp: yes subnet: default mac: 00:00:00:00:00:05 identifier: eth0 From b73bd9402d8119b1e432dd71b500fc6bfe6d805a Mon Sep 17 00:00:00 2001 From: Adam Schaub Date: Mon, 31 Oct 2016 02:52:50 -0400 Subject: [PATCH 3/7] Workflow concept for hosts --- assets/untyped/clevos-answers.provision | 6 ++--- {host_groups => boot}/clevos.yml | 0 {host_groups => boot}/etcd-cluster.yml | 0 {host_groups => boot}/etcd-proxy.yml | 0 sites/test-site/groups.yml | 26 --------------------- sites/test-site/hosts/clevos.yml | 5 +++- sites/test-site/hosts/etcd-masters.yml | 20 +++++++++------- sites/test-site/hosts/etcd-proxy.yml | 4 ++-- workflows/etcd-cluster.yml | 31 +++++++++++++++++++++++++ 9 files changed, 51 insertions(+), 41 deletions(-) rename {host_groups => boot}/clevos.yml (100%) rename {host_groups => boot}/etcd-cluster.yml (100%) rename {host_groups => boot}/etcd-proxy.yml (100%) delete mode 100644 sites/test-site/groups.yml create mode 100644 workflows/etcd-cluster.yml diff --git a/assets/untyped/clevos-answers.provision b/assets/untyped/clevos-answers.provision index 0e0ce39..611d848 100644 --- a/assets/untyped/clevos-answers.provision +++ b/assets/untyped/clevos-answers.provision @@ -12,9 +12,9 @@ reboot = true script: channel data port p6p1, p7p1 channel data bonding balanced channel data bond_xmit_policy layer2 - channel data ip {{.host.ipv4_address}} - channel data netmask {{.env.subnet.netmask}} - channel data gateway {{.env.subnet.gateway}} + channel data ip {{.host.interface.ipv4}} + channel data netmask {{.host.interface.subnet.netmask}} + channel data gateway {{.host.interface.subnet.gateway}} system hostname {{.host.clever_name}} system organization cdvr system city philadelphia diff --git a/host_groups/clevos.yml b/boot/clevos.yml similarity index 100% rename from host_groups/clevos.yml rename to boot/clevos.yml diff --git a/host_groups/etcd-cluster.yml b/boot/etcd-cluster.yml similarity index 100% rename from host_groups/etcd-cluster.yml rename to boot/etcd-cluster.yml diff --git a/host_groups/etcd-proxy.yml b/boot/etcd-proxy.yml similarity index 100% rename from host_groups/etcd-proxy.yml rename to boot/etcd-proxy.yml diff --git a/sites/test-site/groups.yml b/sites/test-site/groups.yml deleted file mode 100644 index 7c48763..0000000 --- a/sites/test-site/groups.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- -host_group: etcd-cluster -selectors: - rootvol: installed -hosts: -- name: host1 - metadata: - etcd_name: node1 -- name: host2 - metadata: - etcd_name: node2 -- name: host3 - metadata: - etcd_name: node3 ---- -host_group: etcd-proxy -hosts: -- name: proxy1 -- name: proxy2 ---- -host_group: clevos -hosts: -- name: clevos1 - metadata: - ipv4_address: 192.128.1.16 - clever_name: haha \ No newline at end of file diff --git a/sites/test-site/hosts/clevos.yml b/sites/test-site/hosts/clevos.yml index 83840b4..d549d42 100644 --- a/sites/test-site/hosts/clevos.yml +++ b/sites/test-site/hosts/clevos.yml @@ -5,4 +5,7 @@ interfaces: subnet: default mac: 00:00:00:00:00:06 ipv4: 192.128.1.16 - hostname: proxy1 \ No newline at end of file + hostname: proxy1 +metadata: + clever_name: haha +workflow: etcd-cluster \ No newline at end of file diff --git a/sites/test-site/hosts/etcd-masters.yml b/sites/test-site/hosts/etcd-masters.yml index 94a50c1..319633b 100644 --- a/sites/test-site/hosts/etcd-masters.yml +++ b/sites/test-site/hosts/etcd-masters.yml @@ -1,35 +1,37 @@ --- name: host1 interfaces: - - type: physical # can be physical/bmc/bond/virtual - dhcp: yes + - type: physical subnet: default mac: 00:00:00:00:00:01 bmc: - type: ipmi # ipmi (specifically over LAN)/cimc/etc + type: ipmi username: adam password: schaub identifier: eth0 ipv4: 10.10.10.10 - hostname: host1 -# could add ipv6 later +metadata: + etcd_name: node1 +workflow: etcd-cluster --- name: host2 interfaces: - type: physical - dhcp: yes subnet: default mac: 00:00:00:00:00:02 identifier: eth0 ipv4: 10.10.10.11 - hostname: host2 +metadata: + etcd_name: node2 +workflow: etcd-cluster --- name: host3 interfaces: - type: physical - dhcp: yes subnet: default mac: 00:00:00:00:00:03 identifier: eth0 ipv4: 10.10.10.12 - hostname: host3 +metadata: + etcd_name: node3 +workflow: etcd-cluster diff --git a/sites/test-site/hosts/etcd-proxy.yml b/sites/test-site/hosts/etcd-proxy.yml index 8fe643a..fc3242f 100644 --- a/sites/test-site/hosts/etcd-proxy.yml +++ b/sites/test-site/hosts/etcd-proxy.yml @@ -6,7 +6,7 @@ interfaces: mac: 00:00:00:00:00:04 identifier: eth0 ipv4: 10.10.10.13 - hostname: proxy1 +workflow: etcd-proxy --- name: proxy2 interfaces: @@ -15,4 +15,4 @@ interfaces: mac: 00:00:00:00:00:05 identifier: eth0 ipv4: 10.10.10.14 - hostname: proxy2 \ No newline at end of file +workflow: etcd-proxy \ No newline at end of file diff --git a/workflows/etcd-cluster.yml b/workflows/etcd-cluster.yml new file mode 100644 index 0000000..894f1c1 --- /dev/null +++ b/workflows/etcd-cluster.yml @@ -0,0 +1,31 @@ +# Workflows chain a series of "boots" together. A host will +# attach itself to a single workflow. A single "boot" is a +# complete provisioning (bootloader & unattended config/install) +id: etcd-cluster +# or boot-order? +workflow: + - boot: wipe-disk + #next-boot: etcd-master <- implicit + metadata: + some: date just for hosts using this workflow + # Some validation? Ignore validation of boot? This probably belongs in the boot object + # A place for policy? Retries, pause after, pause before + - boot: etcd-master + next-boot: etcd-master # next-boot is self, also implicit, as last item + # next-boot: wipe-disk # or go to first stage if rebooted + + +# API call. 0 index the stages enumerated here. +# GET {{ .agentURL }}/config/?stage=0 +# OR +# GET {{ .agentURL }}/config/?boot=wipe-disk + +# Don't use kickstart/cloud-config/ignition. Just /config/?boot= + +# To host state, add "next-boot" that points to the next group +# to use to provision this host. Next-boot is set _after_ a +# successful boot has occurred. + +# Expose an API for setting the "next-boot" of a particular +# host. +# POST {{ .agentURL }} \ No newline at end of file From 963a224545ebee8e95c0964f9b6a705d0131d3a3 Mon Sep 17 00:00:00 2001 From: Adam Schaub Date: Mon, 31 Oct 2016 11:00:41 -0400 Subject: [PATCH 4/7] Host state API concept --- workflows/etcd-cluster.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/workflows/etcd-cluster.yml b/workflows/etcd-cluster.yml index 894f1c1..34a7133 100644 --- a/workflows/etcd-cluster.yml +++ b/workflows/etcd-cluster.yml @@ -28,4 +28,6 @@ workflow: # Expose an API for setting the "next-boot" of a particular # host. -# POST {{ .agentURL }} \ No newline at end of file +# POST {{ .agentURL }}/host/?next-boot=0 +# OR +# POST {{ .agentURL }}/host/?next-boot=wipe-disk From a5def264ec960ba69ca682a58a4a0d7bab5c0920 Mon Sep 17 00:00:00 2001 From: Adam Schaub Date: Thu, 10 Nov 2016 15:43:04 -0500 Subject: [PATCH 5/7] Update to reflect new workflows --- .../{etcd-proxy.yaml => etcd-proxy.yml} | 25 +++--- assets/ignition/etcd-proxy.yaml | 28 ------- assets/ignition/{etcd.yaml => etcd.yml} | 15 ++-- assets/ignition/snippets/etcd.yml | 15 ++++ assets/untyped/clevos-answers.provision | 23 ++++-- boot/clevos.yml | 3 + boot/{etcd-cluster.yml => etcd-master.yml} | 6 +- boot/etcd-proxy.yml | 2 +- sites/test-site/hosts/clevos.yml | 11 --- sites/test-site/hosts/etcd-masters.yml | 37 --------- sites/test-site/hosts/etcd-proxy.yml | 18 ---- sites/test-site/inventory.yml | 82 +++++++++++++++++++ workflows/clevos.yml | 3 + workflows/etcd-cluster.yml | 33 -------- workflows/etcd-master.yml | 9 ++ workflows/etcd-proxy.yml | 3 + 16 files changed, 157 insertions(+), 156 deletions(-) rename assets/cloud-config/{etcd-proxy.yaml => etcd-proxy.yml} (54%) delete mode 100644 assets/ignition/etcd-proxy.yaml rename assets/ignition/{etcd.yaml => etcd.yml} (60%) create mode 100644 assets/ignition/snippets/etcd.yml rename boot/{etcd-cluster.yml => etcd-master.yml} (66%) delete mode 100644 sites/test-site/hosts/clevos.yml delete mode 100644 sites/test-site/hosts/etcd-masters.yml delete mode 100644 sites/test-site/hosts/etcd-proxy.yml create mode 100644 sites/test-site/inventory.yml create mode 100644 workflows/clevos.yml delete mode 100644 workflows/etcd-cluster.yml create mode 100644 workflows/etcd-master.yml create mode 100644 workflows/etcd-proxy.yml diff --git a/assets/cloud-config/etcd-proxy.yaml b/assets/cloud-config/etcd-proxy.yml similarity index 54% rename from assets/cloud-config/etcd-proxy.yaml rename to assets/cloud-config/etcd-proxy.yml index 4ef4346..60c2b47 100644 --- a/assets/cloud-config/etcd-proxy.yaml +++ b/assets/cloud-config/etcd-proxy.yml @@ -6,12 +6,11 @@ coreos: etcd2: proxy: on - # cluster endpoints listen-client-urls: http://0.0.0.0:2379 - initial-cluster: etcd-n1=http://<%= @host.params['etcd-n1'] %>:2380,etcd-n2=http://<%= @host.params['etcd-n2'] %>:2380,etcd-n3=http://<%= @host.params['etcd-n3'] -%>:2380 + initial-cluster: {{ .env.etcd_initial_cluster }} fleet: - metadata: "role=<%= @role %>,vlan=<%= @host.primary_interface.vlanid %>" + metadata: "{{ .boot.fleet_metadata }},vlan={{ .host.subnet.vlan }}" units: - name: down-interfaces.service @@ -19,10 +18,10 @@ coreos: content: | [Service] Type=oneshot - ExecStart=/usr/bin/ip link set <%= @host.interfaces.first.identifier %> down - ExecStart=/usr/bin/ip addr flush dev <%= @host.interfaces.first.identifier %> - ExecStart=/usr/bin/ip link set <%= @host.interfaces.second.identifier %> down - ExecStart=/usr/bin/ip addr flush dev <%= @host.interfaces.second.identifier %> + {{- range $iface := .host.interfaces }} + ExecStart=/usr/bin/ip link set {{ $iface.identifier }} down + ExecStart=/usr/bin/ip addr flush dev {{ $iface.identifier }} + {{ end }} - name: systemd-networkd.service command: restart - name: etcd2.service @@ -60,26 +59,26 @@ write_files: Name=po0 [Link] - MACAddress=<%= @host.interfaces.first.mac %> + MACAddress={{ index .host "interfaces" 0 "mac"}} [Network] DHCP=ipv4 - BindCarrier=<%= @host.interfaces.first.identifier %> <%= @host.interfaces.second.identifier %> - - path: /etc/systemd/network/<%= @host.interfaces.first.identifier %>.network + BindCarrier={{ index .host "interfaces" 0 "identifier" }} {{ index .host "interfaces" 1 "identifier" }} + - path: /etc/systemd/network/{{ index .host "interfaces" 0 "identifier" }}.network permissions: 0644 owner: root content: | [Match] - Name=<%= @host.interfaces.first.identifier %> + Name={{ index .host "interfaces" 0 "identifier" }} [Network] Bond=po0 - - path: /etc/systemd/network/<%= @host.interfaces.second.identifier %>.network + - path: /etc/systemd/network/{{ index .host "interfaces" 1 "identifier" }}.network permissions: 0644 owner: root content: | [Match] - Name=<%= @host.interfaces.second.identifier %> + Name={{ index .host "interfaces" 1 "identifier" }} [Network] Bond=po0 diff --git a/assets/ignition/etcd-proxy.yaml b/assets/ignition/etcd-proxy.yaml deleted file mode 100644 index 7246f68..0000000 --- a/assets/ignition/etcd-proxy.yaml +++ /dev/null @@ -1,28 +0,0 @@ ---- -systemd: - units: - - name: etcd2.service - enable: true - dropins: - - name: 40-etcd-cluster.conf - contents: | - [Service] - Environment="ETCD_PROXY=on" - Environment="ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379" - Environment="ETCD_INITIAL_CLUSTER={{.env.etcd_initial_cluster}}" - - name: fleet.service - enable: true - dropins: - - name: fleet-metadata.conf - contents: | - [Service] - Environment="FLEET_METADATA={{.group.fleet_metadata}}" -{{ if index .env "ssh_authorized_keys" }} -passwd: - users: - - name: core - ssh_authorized_keys: - {{ range $element := .env.ssh_authorized_keys }} - - {{$element}} - {{end}} -{{end}} \ No newline at end of file diff --git a/assets/ignition/etcd.yaml b/assets/ignition/etcd.yml similarity index 60% rename from assets/ignition/etcd.yaml rename to assets/ignition/etcd.yml index 9ce6b0f..521605e 100644 --- a/assets/ignition/etcd.yaml +++ b/assets/ignition/etcd.yml @@ -1,17 +1,20 @@ --- networkd: units: - {{ with index .host.interfaces 0}} - name: 10-static.network contents: | [Match] - MACAddress={{.mac}} + MACAddress={{.interface.mac}} [Network] - Gateway={{.subnet.gateway}} - DNS={{ index .subnet.dns 0 }} - Address={{ .ipv4 }} - {{ end }} + Gateway={{.host.subnet.gateway}} + DNS={{ index .host.subnet.dns 0 }} + Address={{ .interface.ipv4 }} {{ if index .env "ssh_authorized_keys" }} + +systemd: + units: + {{ template "etcd2" .}} + passwd: users: - name: core diff --git a/assets/ignition/snippets/etcd.yml b/assets/ignition/snippets/etcd.yml new file mode 100644 index 0000000..a25f3cc --- /dev/null +++ b/assets/ignition/snippets/etcd.yml @@ -0,0 +1,15 @@ +{{ define "etcd2" }} + - name: etcd2.service + enable: true + dropins: + - name: 40-etcd-cluster.conf + contents: | + [Service] + Environment="ETCD_NAME={{.host.metadata.etcd_name}}" + Environment="ETCD_ADVERTISE_CLIENT_URLS=http://{{.interface.ipv4}}:2379" + Environment="ETCD_INITIAL_ADVERTISE_PEER_URLS=http://{{.interface.ipv4}}:2380" + Environment="ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379" + Environment="ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380" + Environment="ETCD_INITIAL_CLUSTER={{.env.etcd_initial_cluster}}" + Environment="ETCD_STRICT_RECONFIG_CHECK=true" +{{ end }} \ No newline at end of file diff --git a/assets/untyped/clevos-answers.provision b/assets/untyped/clevos-answers.provision index 611d848..780c7cd 100644 --- a/assets/untyped/clevos-answers.provision +++ b/assets/untyped/clevos-answers.provision @@ -9,14 +9,25 @@ confirm = false reboot = true [post] -script: channel data port p6p1, p7p1 +script: channel data port p6p1, p6p2 channel data bonding balanced - channel data bond_xmit_policy layer2 - channel data ip {{.host.interface.ipv4}} - channel data netmask {{.host.interface.subnet.netmask}} - channel data gateway {{.host.interface.subnet.gateway}} - system hostname {{.host.clever_name}} + {{ with index .host.interfaces 0 }} + channel data ip {{ .ipv4 }} + channel data netmask {{ index . "subnet" }} + {{ end }} + channel client port em1, em2 + channel client bonding balanced + {{ with index .host.interfaces 1 }} + channel client ip {{ .ipv4 }} + channel client netmask {{ index . "subnet" }} + channel client gateway {{ index . "subnet" }} + {{ end }} + system hostname {{ .host.name }} system organization cdvr system city philadelphia system state pa system country us + system dns {{ range $i, $dns := .host.subnet.dns }}{{ if $i }},{{ end }}{{ $dns }}{{ end }} + system ntpservers {{ range $i, $ntp := .host.subnet.ntp }}{{ if $i }},{{ end }}{{ $ntp }}{{ end }} + manager ip {{ .host.metadata.manager }} + password {{ .boot.root_pass }} \ No newline at end of file diff --git a/boot/clevos.yml b/boot/clevos.yml index 1671649..71cacd6 100644 --- a/boot/clevos.yml +++ b/boot/clevos.yml @@ -7,3 +7,6 @@ operating_system: clevos-basic # TODO: actually create a ClevOS object unattended: type: untyped use: clevos-answers.provision + +metadata: + root_pass: cisco123 \ No newline at end of file diff --git a/boot/etcd-cluster.yml b/boot/etcd-master.yml similarity index 66% rename from boot/etcd-cluster.yml rename to boot/etcd-master.yml index 92ed90d..8cc3403 100644 --- a/boot/etcd-cluster.yml +++ b/boot/etcd-master.yml @@ -1,12 +1,12 @@ --- -id: etcd-cluster -name: Etcd Cluster +id: etcd-master +name: Etcd Master operating_system: coreos-1053.2.0-stable unattended: type: ignition - use: etcd.yaml + use: etcd.yml metadata: fleet_role: etcd diff --git a/boot/etcd-proxy.yml b/boot/etcd-proxy.yml index 8f8c61c..fb9a4e9 100644 --- a/boot/etcd-proxy.yml +++ b/boot/etcd-proxy.yml @@ -6,7 +6,7 @@ operating_system: coreos-1053.2.0-stable unattended: type: cloud-config - use: etcd-proxy.yaml + use: etcd-proxy.yml metadata: fleet_metadata: role=etcd-proxy diff --git a/sites/test-site/hosts/clevos.yml b/sites/test-site/hosts/clevos.yml deleted file mode 100644 index d549d42..0000000 --- a/sites/test-site/hosts/clevos.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -name: clevos1 -interfaces: - - type: physical - subnet: default - mac: 00:00:00:00:00:06 - ipv4: 192.128.1.16 - hostname: proxy1 -metadata: - clever_name: haha -workflow: etcd-cluster \ No newline at end of file diff --git a/sites/test-site/hosts/etcd-masters.yml b/sites/test-site/hosts/etcd-masters.yml deleted file mode 100644 index 319633b..0000000 --- a/sites/test-site/hosts/etcd-masters.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -name: host1 -interfaces: - - type: physical - subnet: default - mac: 00:00:00:00:00:01 - bmc: - type: ipmi - username: adam - password: schaub - identifier: eth0 - ipv4: 10.10.10.10 -metadata: - etcd_name: node1 -workflow: etcd-cluster ---- -name: host2 -interfaces: - - type: physical - subnet: default - mac: 00:00:00:00:00:02 - identifier: eth0 - ipv4: 10.10.10.11 -metadata: - etcd_name: node2 -workflow: etcd-cluster ---- -name: host3 -interfaces: - - type: physical - subnet: default - mac: 00:00:00:00:00:03 - identifier: eth0 - ipv4: 10.10.10.12 -metadata: - etcd_name: node3 -workflow: etcd-cluster diff --git a/sites/test-site/hosts/etcd-proxy.yml b/sites/test-site/hosts/etcd-proxy.yml deleted file mode 100644 index fc3242f..0000000 --- a/sites/test-site/hosts/etcd-proxy.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -name: proxy1 -interfaces: - - type: physical - subnet: default - mac: 00:00:00:00:00:04 - identifier: eth0 - ipv4: 10.10.10.13 -workflow: etcd-proxy ---- -name: proxy2 -interfaces: - - type: physical - subnet: default - mac: 00:00:00:00:00:05 - identifier: eth0 - ipv4: 10.10.10.14 -workflow: etcd-proxy \ No newline at end of file diff --git a/sites/test-site/inventory.yml b/sites/test-site/inventory.yml new file mode 100644 index 0000000..9b307d5 --- /dev/null +++ b/sites/test-site/inventory.yml @@ -0,0 +1,82 @@ +--- +name: host1 +interfaces: + - type: physical + subnet: default + mac: 00:00:00:00:00:01 + bmc: + type: ipmi + username: adam + password: schaub + identifier: eth0 + ipv4: 10.10.10.10 +metadata: + etcd_name: node1 +workflow: etcd-master +--- +name: host2 +interfaces: + - type: physical + subnet: default + mac: 00:00:00:00:00:02 + identifier: eth0 + ipv4: 10.10.10.11 +metadata: + etcd_name: node2 +workflow: etcd-master +--- +name: host3 +interfaces: + - type: physical + subnet: default + mac: 00:00:00:00:00:03 + identifier: eth0 + ipv4: 10.10.10.12 +metadata: + etcd_name: node3 +workflow: etcd-master +--- +name: proxy1 +interfaces: + - type: physical + subnet: default + mac: 00:00:00:00:00:04 + identifier: eth0 + ipv4: 10.10.10.13 + - type: physical + subnet: default + mac: 00:00:00:00:00:14 + identifier: eth1 + ipv4: 10.10.10.23 +workflow: etcd-proxy +--- +name: proxy2 +interfaces: + - type: physical + subnet: default + mac: 00:00:00:00:00:05 + identifier: eth0 + ipv4: 10.10.10.14 + - type: physical + subnet: default + mac: 00:00:00:00:00:15 + identifier: eth1 + ipv4: 10.10.10.24 +workflow: etcd-proxy +--- +name: clevos1 +interfaces: + - type: physical + subnet: default + mac: 00:00:00:00:00:06 + ipv4: 10.10.10.15 + identifier: eth0 + hostname: clevos1 + - type: physical + subnet: default + mac: 00:00:00:00:01:06 + ipv4: 192.128.1.16 + identifier: eth1 +metadata: + manager: 10.10.10.10 +workflow: clevos \ No newline at end of file diff --git a/workflows/clevos.yml b/workflows/clevos.yml new file mode 100644 index 0000000..b028f33 --- /dev/null +++ b/workflows/clevos.yml @@ -0,0 +1,3 @@ +id: clevos +workflow: + - boot: clevos \ No newline at end of file diff --git a/workflows/etcd-cluster.yml b/workflows/etcd-cluster.yml deleted file mode 100644 index 34a7133..0000000 --- a/workflows/etcd-cluster.yml +++ /dev/null @@ -1,33 +0,0 @@ -# Workflows chain a series of "boots" together. A host will -# attach itself to a single workflow. A single "boot" is a -# complete provisioning (bootloader & unattended config/install) -id: etcd-cluster -# or boot-order? -workflow: - - boot: wipe-disk - #next-boot: etcd-master <- implicit - metadata: - some: date just for hosts using this workflow - # Some validation? Ignore validation of boot? This probably belongs in the boot object - # A place for policy? Retries, pause after, pause before - - boot: etcd-master - next-boot: etcd-master # next-boot is self, also implicit, as last item - # next-boot: wipe-disk # or go to first stage if rebooted - - -# API call. 0 index the stages enumerated here. -# GET {{ .agentURL }}/config/?stage=0 -# OR -# GET {{ .agentURL }}/config/?boot=wipe-disk - -# Don't use kickstart/cloud-config/ignition. Just /config/?boot= - -# To host state, add "next-boot" that points to the next group -# to use to provision this host. Next-boot is set _after_ a -# successful boot has occurred. - -# Expose an API for setting the "next-boot" of a particular -# host. -# POST {{ .agentURL }}/host/?next-boot=0 -# OR -# POST {{ .agentURL }}/host/?next-boot=wipe-disk diff --git a/workflows/etcd-master.yml b/workflows/etcd-master.yml new file mode 100644 index 0000000..7505c77 --- /dev/null +++ b/workflows/etcd-master.yml @@ -0,0 +1,9 @@ +# Workflows chain a series of "boots" together. A host will +# attach itself to a single workflow. A single "boot" is a +# complete provisioning (bootloader & unattended config/install) +id: etcd-master +# or boot-order? +workflow: + - boot: etcd-master + next-boot: etcd-master # next-boot is self, also implicit, as last item + # next-boot: wipe-disk # or go to first stage if rebooted diff --git a/workflows/etcd-proxy.yml b/workflows/etcd-proxy.yml new file mode 100644 index 0000000..a42d837 --- /dev/null +++ b/workflows/etcd-proxy.yml @@ -0,0 +1,3 @@ +id: etcd-proxy +workflow: + - boot: etcd-proxy \ No newline at end of file From 1549a5de55e49b603ff0b64cc718671dfa5ffbe5 Mon Sep 17 00:00:00 2001 From: Adam Schaub Date: Thu, 10 Nov 2016 15:59:33 -0500 Subject: [PATCH 6/7] Whoopsie on the etcd-master template --- assets/ignition/etcd.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/assets/ignition/etcd.yml b/assets/ignition/etcd.yml index 521605e..afd243e 100644 --- a/assets/ignition/etcd.yml +++ b/assets/ignition/etcd.yml @@ -9,12 +9,13 @@ networkd: Gateway={{.host.subnet.gateway}} DNS={{ index .host.subnet.dns 0 }} Address={{ .interface.ipv4 }} -{{ if index .env "ssh_authorized_keys" }} systemd: units: - {{ template "etcd2" .}} + {{- template "etcd2" .}} + +{{ if index .env "ssh_authorized_keys" }} passwd: users: - name: core From fb33d2ca9cdef06e47ad8500aa69dd4e27fe4b2b Mon Sep 17 00:00:00 2001 From: Adam Schaub Date: Tue, 15 Nov 2016 14:23:40 -0500 Subject: [PATCH 7/7] Fix for metadata changes --- assets/cloud-config/etcd-proxy.yml | 4 ++-- assets/ignition/etcd.yml | 4 ++-- assets/ignition/snippets/etcd.yml | 4 ++-- assets/untyped/clevos-answers.provision | 12 ++++++------ os/clevos-basic.yml | 6 +++--- os/coreos-pxe.yml | 4 ++-- sites/test-site/env.yml | 7 +------ sites/test-site/inventory.yml | 2 +- 8 files changed, 19 insertions(+), 24 deletions(-) diff --git a/assets/cloud-config/etcd-proxy.yml b/assets/cloud-config/etcd-proxy.yml index 60c2b47..9600d92 100644 --- a/assets/cloud-config/etcd-proxy.yml +++ b/assets/cloud-config/etcd-proxy.yml @@ -7,10 +7,10 @@ coreos: etcd2: proxy: on listen-client-urls: http://0.0.0.0:2379 - initial-cluster: {{ .env.etcd_initial_cluster }} + initial-cluster: {{ .env.md.etcd_initial_cluster }} fleet: - metadata: "{{ .boot.fleet_metadata }},vlan={{ .host.subnet.vlan }}" + metadata: "{{ .boot.md.fleet_metadata }},vlan={{ .interface.subnet.vlan }}" units: - name: down-interfaces.service diff --git a/assets/ignition/etcd.yml b/assets/ignition/etcd.yml index afd243e..878564f 100644 --- a/assets/ignition/etcd.yml +++ b/assets/ignition/etcd.yml @@ -6,8 +6,8 @@ networkd: [Match] MACAddress={{.interface.mac}} [Network] - Gateway={{.host.subnet.gateway}} - DNS={{ index .host.subnet.dns 0 }} + Gateway={{.interface.subnet.gateway}} + DNS={{ index .interface.subnet.dns 0 }} Address={{ .interface.ipv4 }} systemd: diff --git a/assets/ignition/snippets/etcd.yml b/assets/ignition/snippets/etcd.yml index a25f3cc..1372f21 100644 --- a/assets/ignition/snippets/etcd.yml +++ b/assets/ignition/snippets/etcd.yml @@ -5,11 +5,11 @@ - name: 40-etcd-cluster.conf contents: | [Service] - Environment="ETCD_NAME={{.host.metadata.etcd_name}}" + Environment="ETCD_NAME={{.host.md.etcd_name}}" Environment="ETCD_ADVERTISE_CLIENT_URLS=http://{{.interface.ipv4}}:2379" Environment="ETCD_INITIAL_ADVERTISE_PEER_URLS=http://{{.interface.ipv4}}:2380" Environment="ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379" Environment="ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380" - Environment="ETCD_INITIAL_CLUSTER={{.env.etcd_initial_cluster}}" + Environment="ETCD_INITIAL_CLUSTER={{.env.md.etcd_initial_cluster}}" Environment="ETCD_STRICT_RECONFIG_CHECK=true" {{ end }} \ No newline at end of file diff --git a/assets/untyped/clevos-answers.provision b/assets/untyped/clevos-answers.provision index 780c7cd..ee65a25 100644 --- a/assets/untyped/clevos-answers.provision +++ b/assets/untyped/clevos-answers.provision @@ -13,21 +13,21 @@ script: channel data port p6p1, p6p2 channel data bonding balanced {{ with index .host.interfaces 0 }} channel data ip {{ .ipv4 }} - channel data netmask {{ index . "subnet" }} + channel data netmask {{ .subnet.netmask }} {{ end }} channel client port em1, em2 channel client bonding balanced {{ with index .host.interfaces 1 }} channel client ip {{ .ipv4 }} - channel client netmask {{ index . "subnet" }} - channel client gateway {{ index . "subnet" }} + channel client netmask {{ .subnet.netmask }} + channel client gateway {{ .subnet.gateway }} {{ end }} system hostname {{ .host.name }} system organization cdvr system city philadelphia system state pa system country us - system dns {{ range $i, $dns := .host.subnet.dns }}{{ if $i }},{{ end }}{{ $dns }}{{ end }} - system ntpservers {{ range $i, $ntp := .host.subnet.ntp }}{{ if $i }},{{ end }}{{ $ntp }}{{ end }} + system dns {{ range $i, $dns := .interface.subnet.dns }}{{ if $i }},{{ end }}{{ $dns }}{{ end }} + system ntpservers {{ range $i, $ntp := .interface.subnet.ntp }}{{ if $i }},{{ end }}{{ $ntp }}{{ end }} manager ip {{ .host.metadata.manager }} - password {{ .boot.root_pass }} \ No newline at end of file + password {{ .boot.metadata.root_pass }} \ No newline at end of file diff --git a/os/clevos-basic.yml b/os/clevos-basic.yml index 33969dc..ed8bc89 100644 --- a/os/clevos-basic.yml +++ b/os/clevos-basic.yml @@ -6,9 +6,9 @@ minor_version: '7.2' os_family: ClevOS release_name: acc boot: - kernel: "{{.agent.url}}/files/boot/accclevos.vmlinuz" + kernel: "{{.env.agentURL}}/files/boot/accclevos.vmlinuz" initrd: - - "{{.agent.url}}/files/boot/acc/clevos.initrd" + - "{{.env.agentURL}}/files/boot/acc/clevos.initrd" cmdline: # Have to manually specify 'untyped' kernel opts lang: ' ' @@ -23,7 +23,7 @@ cmdline: ethdevice-timeout: '300' clevos.runinstall: noprompt: - clevos.installer.answers: "{{.host.configUrl}}" # configUrl is the full URL (with selectors) for this host's unattened config script + clevos.installer.answers: "{{.boot.configURL}}" # configUrl is the full URL (with selectors) for this host's unattened config script dhcp: config: fetch: \ No newline at end of file diff --git a/os/coreos-pxe.yml b/os/coreos-pxe.yml index 893284c..eda3f2d 100644 --- a/os/coreos-pxe.yml +++ b/os/coreos-pxe.yml @@ -6,8 +6,8 @@ minor_version: '2.0' os_family: CoreOS release_name: stable boot: - kernel: "{{.agent.url}}/files/coreos_production_pxe.vmlinuz" + kernel: "{{.env.agentURL}}/files/{{.boot.os.release_name}}/{{.boot.os.major_version}}/{{.boot.os.minor_version}}/coreos_production_pxe.vmlinuz" initrd: - - "{{.agent.url}}/files/coreos_production_pxe_image.cpio.gz" + - "{{.env.agentURL}}/files/coreos_production_pxe_image.cpio.gz" cmdline: coreos.autologin: '' diff --git a/sites/test-site/env.yml b/sites/test-site/env.yml index 0c6a2ef..5678c94 100644 --- a/sites/test-site/env.yml +++ b/sites/test-site/env.yml @@ -5,6 +5,7 @@ subnets: - id: default cidr: 10.10.10.0/24 domain: foo.bar.com + gateway: 10.10.10.1 dns: - 8.8.8.8 ntp: @@ -36,11 +37,5 @@ metadata: kind: pre-prod etcd_initial_cluster: node1=http://10.10.10.10:2380,node2=http://10.10.10.11:2380,node3=http://10.10.10.12:2380 - networkd_gateway: 172.15.0.1 - networkd_dns: 172.15.0.3 - - subnet: - gateway: 192.168.1.1 - netmask: 255.255.255.0 ssh_authorized_keys: [] diff --git a/sites/test-site/inventory.yml b/sites/test-site/inventory.yml index 9b307d5..f7ae62f 100644 --- a/sites/test-site/inventory.yml +++ b/sites/test-site/inventory.yml @@ -73,7 +73,7 @@ interfaces: identifier: eth0 hostname: clevos1 - type: physical - subnet: default + subnet: clevos mac: 00:00:00:00:01:06 ipv4: 192.128.1.16 identifier: eth1