{"action":"created","issue":{"url":"https://api.github.com/repos/saltstack/salt/issues/24938","labels_url":"https://api.github.com/repos/saltstack/salt/issues/24938/labels{/name}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/24938/comments","events_url":"https://api.github.com/repos/saltstack/salt/issues/24938/events","html_url":"https://github.com/saltstack/salt/issues/24938","id":90742279,"number":24938,"title":"Add \"predictive changes\" field to State functions","user":{"login":"whiteinge","id":91293,"avatar_url":"https://avatars.githubusercontent.com/u/91293?v=3","gravatar_id":"","url":"https://api.github.com/users/whiteinge","html_url":"https://github.com/whiteinge","followers_url":"https://api.github.com/users/whiteinge/followers","following_url":"https://api.github.com/users/whiteinge/following{/other_user}","gists_url":"https://api.github.com/users/whiteinge/gists{/gist_id}","starred_url":"https://api.github.com/users/whiteinge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whiteinge/subscriptions","organizations_url":"https://api.github.com/users/whiteinge/orgs","repos_url":"https://api.github.com/users/whiteinge/repos","events_url":"https://api.github.com/users/whiteinge/events{/privacy}","received_events_url":"https://api.github.com/users/whiteinge/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/saltstack/salt/labels/Feature","name":"Feature","color":"009800"},{"url":"https://api.github.com/repos/saltstack/salt/labels/Pending%20Discussion","name":"Pending Discussion","color":"c7def8"},{"url":"https://api.github.com/repos/saltstack/salt/labels/State%20Module","name":"State Module","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/saltstack/salt/milestones/13","html_url":"https://github.com/saltstack/salt/milestones/Approved","labels_url":"https://api.github.com/repos/saltstack/salt/milestones/13/labels","id":9265,"number":13,"title":"Approved","description":"All issues that are ready to be worked on, both bugs and features.","creator":{"login":"thatch45","id":507599,"avatar_url":"https://avatars.githubusercontent.com/u/507599?v=3","gravatar_id":"","url":"https://api.github.com/users/thatch45","html_url":"https://github.com/thatch45","followers_url":"https://api.github.com/users/thatch45/followers","following_url":"https://api.github.com/users/thatch45/following{/other_user}","gists_url":"https://api.github.com/users/thatch45/gists{/gist_id}","starred_url":"https://api.github.com/users/thatch45/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thatch45/subscriptions","organizations_url":"https://api.github.com/users/thatch45/orgs","repos_url":"https://api.github.com/users/thatch45/repos","events_url":"https://api.github.com/users/thatch45/events{/privacy}","received_events_url":"https://api.github.com/users/thatch45/received_events","type":"User","site_admin":false},"open_issues":2388,"closed_issues":2205,"state":"open","created_at":"2011-05-14T04:00:56Z","updated_at":"2015-06-24T17:46:37Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2015-06-24T17:46:37Z","updated_at":"2015-06-24T17:59:06Z","closed_at":null,"body":"The `changes` dictionary common to all functions in Salt state modules contains a wealth of information that can be read by humans but also used programmatically.\r\n\r\nAs an obvious example, a long-term external job cache of highstate runs would contain diffs of all changes to a file managed using the `file.managed` state. Meaning you could programmatically determine things like volume of changes made during the last year, frequency of changes made by day/week/month, etc.\r\n\r\nHowever this same data is not easily available in dry-run mode because it is stuffed into the `comment` field as a string. In addition to not being programmatically accessible, it makes for a certain asymmetry between real state runs and dry-runs. For example, it would be great to be able to compare (both manually and programmatically) the difference between a dry-run and a real run. There are certain kinds of data that are simply not possible to know in advance, and so being able to see those after a real run would be useful. As an example, a `file.managed` can manually set user/group/perms/etc but sometimes system defaults will determine those data points when not explicitly defined in Salt and it would be useful to see both in the state output.\r\n\r\nWe can't change the existing contract of the `changes` dictionary for dry-run mode plus, as mentioned above, it can be confusing since it may not match exactly between a real state run and a dry run. To that end, @thatch45 proposed we add a `predictive_changes` field to all state runs.\r\n\r\nThe `predictive_changes` field will be a _dictionary_ that collects all the changes that we _expect_ a state run to make to the underlying system. It will be present in a dry-run mode as well as an actual run.\r\n\r\nWe're already doing most of the ground-work to populate this dictionary in existing state modules. This gives us a place to put all that system discovery work for display.\r\n\r\nRelated issues: #12830, #17939, #24437."},"comment":{"url":"https://api.github.com/repos/saltstack/salt/issues/comments/114959298","html_url":"https://github.com/saltstack/salt/issues/24938#issuecomment-114959298","issue_url":"https://api.github.com/repos/saltstack/salt/issues/24938","id":114959298,"user":{"login":"whiteinge","id":91293,"avatar_url":"https://avatars.githubusercontent.com/u/91293?v=3","gravatar_id":"","url":"https://api.github.com/users/whiteinge","html_url":"https://github.com/whiteinge","followers_url":"https://api.github.com/users/whiteinge/followers","following_url":"https://api.github.com/users/whiteinge/following{/other_user}","gists_url":"https://api.github.com/users/whiteinge/gists{/gist_id}","starred_url":"https://api.github.com/users/whiteinge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whiteinge/subscriptions","organizations_url":"https://api.github.com/users/whiteinge/orgs","repos_url":"https://api.github.com/users/whiteinge/repos","events_url":"https://api.github.com/users/whiteinge/events{/privacy}","received_events_url":"https://api.github.com/users/whiteinge/received_events","type":"User","site_admin":false},"created_at":"2015-06-24T17:59:06Z","updated_at":"2015-06-24T17:59:06Z","body":"Salt states, as they exist today, are sort of self-verifying in that they must perform pre-checks (\"does anything on the system need to change?\") before making the change as well as a post-check (\"what on the system did change?\") in order to create the `changes` dictionary.\r\n\r\nThat makes kicking off a dry-run useful in order to verify a previous state run. In other words, rather than write tests (ala rspec) that check the state of a system after a state run Salt, in a sense, has that feature built-in. Exposing more of that information will make for better, more transparent, more useful dry-runs."}}