Skip to content

Commit

Permalink
Merge pull request #29 from mapuri/ansible_catchup
Browse files Browse the repository at this point in the history
align cluster-manager to recent ansible changes
  • Loading branch information
mapuri committed Dec 17, 2015
2 parents cfa5bc7 + a2d4b2b commit 2d0f548
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
11 changes: 6 additions & 5 deletions management/src/clusterm/manager/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ const (
)

const (
ansibleMasterGroupName = "service-master"
ansibleWorkerGroupName = "service-worker"
ansibleNodeNameHostVar = "node_name"
ansibleNodeAddrHostVar = "node_addr"
ansibleOnlineMasterAddrHostVar = "online_master_addr"
ansibleMasterGroupName = "service-master"
ansibleWorkerGroupName = "service-worker"
ansibleNodeNameHostVar = "node_name"
ansibleNodeAddrHostVar = "node_addr"
ansibleEtcdMasterAddrHostVar = "etcd_master_addr"
ansibleEtcdMasterNameHostVar = "etcd_master_name"
)
13 changes: 10 additions & 3 deletions management/src/clusterm/manager/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ func (e *nodeConfigure) process() error {

hostInfo := e.mgr.nodes[e.nodeName].cInfo.(*configuration.AnsibleHost)
nodeGroup := ansibleMasterGroupName
onlineMasterAddr := ""
masterAddr := ""
masterName := ""
// update the online master address if this is second node that is being commissioned.
// Also set the group for second or later nodes to be worker, as right now services like
// swarm and netmaster can only have one master node and also we don't yet have a vip
Expand All @@ -257,12 +258,18 @@ func (e *nodeConfigure) process() error {
// skip hosts that are not yet provisioned or not in discovered state
continue
}
if node.cInfo.GetGroup() != ansibleMasterGroupName {
//skip the hosts that are not in master group
continue
}
// found our node
onlineMasterAddr = node.mInfo.GetMgmtAddress()
masterAddr = node.mInfo.GetMgmtAddress()
masterName = node.cInfo.GetTag()
nodeGroup = ansibleWorkerGroupName
}
hostInfo.SetGroup(nodeGroup)
hostInfo.SetVar(ansibleOnlineMasterAddrHostVar, onlineMasterAddr)
hostInfo.SetVar(ansibleEtcdMasterAddrHostVar, masterAddr)
hostInfo.SetVar(ansibleEtcdMasterNameHostVar, masterName)
outReader, errCh := e.mgr.configuration.Configure(
configuration.SubsysHosts([]*configuration.AnsibleHost{hostInfo}), e.extraVars)
if err := logOutputAndReturnStatus(outReader, errCh); err != nil {
Expand Down
10 changes: 10 additions & 0 deletions management/src/configuration/ansible.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ func NewAnsibleHost(tag, addr, group string, vars map[string]string) *AnsibleHos
}
}

// GetTag return the ansible inventory name/tag for the host
func (h *AnsibleHost) GetTag() string {
return h.tag
}

// GetGroup return the ansible inventory group/role for the host
func (h *AnsibleHost) GetGroup() string {
return h.group
}

// SetVar sets a host variable value
func (h *AnsibleHost) SetVar(key, val string) {
h.vars[key] = val
Expand Down
7 changes: 6 additions & 1 deletion management/src/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ type Subsys interface {
}

// SubsysHost denotes a host in configuration subsystem
type SubsysHost interface{}
type SubsysHost interface {
// GetTag returns the name/tag associated with the host in configuration sub-system
GetTag() string
//GetGroup returns the group/role associated with the host in configuration sub-system
GetGroup() string
}

// SubsysHosts denotes a collection of hosts in configuration subsystem
type SubsysHosts interface{}

0 comments on commit 2d0f548

Please sign in to comment.