github.skymusic.top/operator-framework/operator-sdk@v0.8.2/doc/ansible/information-flow-ansible-operator.md (about) 1 # Information Flow for Ansible Operator 2 3 ![Ansible Operator Flow](ao-flow.png) 4 5 ### Controller/Reconciler 6 * Gets the primary resource based on NamespacedName this uses the cache from controller runtime. 7 * Determines if the resource is deleted based on the existence of a finalizer and a metadata.DeletionTimeStamp. 8 * If deleted and not one of our finalizers we exit with no error. 9 * If finalizer is needed, but is not on the object, and is not deleted then add it and continue. 10 * Marks the status of the CR as running if it is managing the status and continues 11 * Creates the proxy’s kubeconfig. 12 * Calls out Runner using the runner package. 13 * Watches for events to come back across the results channel. 14 * Logs the events 15 * Keeps track of failure messages as well as the StatusEvent, which is the ending event that the Ansible sends to mark the playbook/role is completed. 16 * If a finalizer exists and the resource was deleted then remove the finalizer and update the object and continue. 17 * Update the status of the resource to mark that the run has completed 18 19 ### Runner Package 20 * Create the socket that ansible will communicate over 21 * Translate object.Spec -> ansible vars (camelCase -> camel_case) and adds them as parameters for the ansible-runner directory. 22 * Create the directory on disk for ansible runner. or update the files on disk if they already exist. 23 * Run the ansible runner command in a go routine, when this exits close the channel for the socket. 24 25 ### The Proxy 26 * Every request to the k8s api goes through the proxy. 27 * The owner reference is injected into the object that is being created. 28 * The proxy then adds dependent watches for the correct controller if we have not started watching the type already 29 * On a GET, we attempt to use the informer cache to get the resource. This will also attempt to re-add dependent watches if we find a type with an owner reference. 30 31 ### Ansible Runner 32 * Ansible is run and has its own process. 33 * Ansible-runner-http package allows runner to set us ansible events as ansible is being run. ansible runner uses the socket and the controller is watching the events as they come through the channel. 34 35 36 37 38 39 40 41