{"action":"created","issue":{"url":"https://api.github.com/repos/purpleidea/mgmt/issues/277","repository_url":"https://api.github.com/repos/purpleidea/mgmt","labels_url":"https://api.github.com/repos/purpleidea/mgmt/issues/277/labels{/name}","comments_url":"https://api.github.com/repos/purpleidea/mgmt/issues/277/comments","events_url":"https://api.github.com/repos/purpleidea/mgmt/issues/277/events","html_url":"https://github.com/purpleidea/mgmt/issues/277","id":278228718,"number":277,"title":"New Resource: Remote Execution","user":{"login":"purpleidea","id":135091,"avatar_url":"https://avatars0.githubusercontent.com/u/135091?v=4","gravatar_id":"","url":"https://api.github.com/users/purpleidea","html_url":"https://github.com/purpleidea","followers_url":"https://api.github.com/users/purpleidea/followers","following_url":"https://api.github.com/users/purpleidea/following{/other_user}","gists_url":"https://api.github.com/users/purpleidea/gists{/gist_id}","starred_url":"https://api.github.com/users/purpleidea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/purpleidea/subscriptions","organizations_url":"https://api.github.com/users/purpleidea/orgs","repos_url":"https://api.github.com/users/purpleidea/repos","events_url":"https://api.github.com/users/purpleidea/events{/privacy}","received_events_url":"https://api.github.com/users/purpleidea/received_events","type":"User","site_admin":false},"labels":[{"id":737436248,"url":"https://api.github.com/repos/purpleidea/mgmt/labels/design","name":"design","color":"5319e7","default":false},{"id":264866247,"url":"https://api.github.com/repos/purpleidea/mgmt/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-11-30T18:47:06Z","updated_at":"2018-02-28T21:41:01Z","closed_at":null,"author_association":"OWNER","body":"## Background\r\n\r\nIn mgmt I implemented a core \"remote execution\" feature. A blog post about this is available:\r\nhttps://ttboj.wordpress.com/2016/10/07/remote-execution-in-mgmt/\r\nOne of my goals with this feature was to show how bootstrapping new clusters could be achieved (one of the _valid_ uses for central orchestration IMHO) and to show how a distributed system that operates like mgmt can have remote execution as a special case.\r\n\r\n## Problem\r\n\r\nThere are a few problems with the current implementation:\r\n\r\n### 0) Some of the code is in need of a clean up.\r\n\r\nI should have gone with a \"populate struct\" + `Init() error` model instead of the giant `New()` constructor which I implemented.\r\n\r\n### 1) It has rotted a bit since golang (which doesn't break API) broke API and it now fails with:\r\n\r\n```remote.go:1021: Remote: Error: Remote: SSH errored with: Can't dial: ssh: must specify HostKeyCallback```\r\n\r\nThis is because host key checking is now mandatory and it wasn't previously implemented. See:\r\nhttps://godoc.org/golang.org/x/crypto/ssh#HostKeyCallback\r\n\r\nPatches are welcome.\r\n\r\n### 2) The remote execution code is run from the lib/main.go entry point which complicates the logic.\r\n\r\nThis can be improved. See below for a solution.\r\n\r\n### 3) Dynamic, code-controlled remote execution could be more useful and powerful.\r\n\r\nFitting the current implementation into the language model is difficult.\r\n\r\n## Solution\r\n\r\nI realized that this could be re-implemented as a `remote` resource. https://github.com/purpleidea/mgmt/blob/master/docs/resource-guide.md -- The resource could take arguments as we currently do and kick off connections when needed.\r\n\r\nThis would pull it out of the main body and into a resource which is cleaner. Also it would allow all the power of the language in order to make this more dynamic.\r\n\r\n## Bonus\r\n\r\nAs a bonus to this change, we could even implement a small GAPI frontend which creates a small graph with `remote` resources to emulate the current CLI mode of operation.\r\n\r\n## Conclusion\r\n\r\nThis is a bit of a tricky issue, but good for a medium golang hacker preferably with at lease medium experience with the golang API. We're happy to mentor you if you'd like to write this!\r\n\r\nHappy Hacking!"},"comment":{"url":"https://api.github.com/repos/purpleidea/mgmt/issues/comments/369392639","html_url":"https://github.com/purpleidea/mgmt/issues/277#issuecomment-369392639","issue_url":"https://api.github.com/repos/purpleidea/mgmt/issues/277","id":369392639,"user":{"login":"purpleidea","id":135091,"avatar_url":"https://avatars0.githubusercontent.com/u/135091?v=4","gravatar_id":"","url":"https://api.github.com/users/purpleidea","html_url":"https://github.com/purpleidea","followers_url":"https://api.github.com/users/purpleidea/followers","following_url":"https://api.github.com/users/purpleidea/following{/other_user}","gists_url":"https://api.github.com/users/purpleidea/gists{/gist_id}","starred_url":"https://api.github.com/users/purpleidea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/purpleidea/subscriptions","organizations_url":"https://api.github.com/users/purpleidea/orgs","repos_url":"https://api.github.com/users/purpleidea/repos","events_url":"https://api.github.com/users/purpleidea/events{/privacy}","received_events_url":"https://api.github.com/users/purpleidea/received_events","type":"User","site_admin":false},"created_at":"2018-02-28T21:41:01Z","updated_at":"2018-02-28T21:41:01Z","author_association":"OWNER","body":"Design note:\r\n\r\nI was thinking about how the `Watch` part of this resource should work. Here's one idea:\r\n\r\nWatch should open up a connection to our local etcd store on the membership list. When we `remote` to a new host and \"bootstrap\" it, it will join the cluster. Once that's done, we'll get an event :) If it ever disconnects from the cluster, we'll get a \"remove\" event, and we can run `CheckApply` again.\r\n\r\nWe might need a way to detect if a machine is running an mgmt instance happily or not. In particular so that the `CheckApply` portion can have something to easily check. It could (1) check just by looking at etcd membership, or (2) have an option to check by logging in and running ps or something similar. There could be many ways to check.\r\n\r\n"}}
{"actor":{"display_login":"purpleidea"}}