Module and states code refactor

Change-Id: Ia1c468d0b55603b6274ca0d275b2720602e5319e
diff --git a/_states/jenkins_user.py b/_states/jenkins_user.py
index c2f2d9b..ed34877 100644
--- a/_states/jenkins_user.py
+++ b/_states/jenkins_user.py
@@ -1,40 +1,41 @@
 import logging
+
 logger = logging.getLogger(__name__)
 
 create_admin_groovy = u"""\
 import jenkins.model.*
 import hudson.security.*
 def instance = Jenkins.getInstance()
-if(hudson.model.User.getAll().find{{u->u.fullName.equals("{username}")}}){{
+if(hudson.model.User.getAll().find{u->u.fullName.equals("${username}")}){
     print("EXISTS")
-}}else{{
+}else{
     def hudsonRealm = new HudsonPrivateSecurityRealm(false)
-    def result=hudsonRealm.createAccount("{username}","{password}")
+    def result=hudsonRealm.createAccount("${username}","${password}")
     instance.setSecurityRealm(hudsonRealm)
     def strategy = new hudson.security.FullControlOnceLoggedInAuthorizationStrategy()
     strategy.setAllowAnonymousRead(false)
     instance.setAuthorizationStrategy(strategy)
     instance.save()
-    if(result.toString().equals("{username}")){{
+    if(result.toString().equals("${username}")){
         print("SUCCESS")
-    }}else{{
+    }else{
         print("FAILED")
-    }}
-}}
+    }
+}
 """  # noqa
 
 
 create_user_groovy = u"""\
-if(hudson.model.User.getAll().find{{u->u.fullName.equals("{username}")}}){{
+if(hudson.model.User.getAll().find{u->u.fullName.equals("${username}")}){
     print("EXISTS")
-}}else{{
-    def result=jenkins.model.Jenkins.instance.securityRealm.createAccount("{username}", "{password}")
-    if(result.toString().equals("{username}")){{
+}else{
+    def result=jenkins.model.Jenkins.instance.securityRealm.createAccount("${username}", "${password}")
+    if(result.toString().equals("${username}")){
         print("SUCCESS")
-    }}else{{
+    }else{
         print("FAILED")
-    }}
-}}
+    }
+}
 """  # noqa
 
 
@@ -75,7 +76,8 @@
     else:
         call_result = __salt__['jenkins_common.call_groovy_script'](
             create_admin_groovy if admin else create_user_groovy, {"username": username, "password": password})
-        if call_result["code"] == 200 and call_result["msg"] in ["SUCCESS", "EXISTS"]:
+        if call_result["code"] == 200 and call_result["msg"] in [
+                "SUCCESS", "EXISTS"]:
             if call_result["msg"] == "SUCCESS":
                 status = "CREATED" if not admin else "ADMIN CREATED"
                 ret['changes'][username] = status