DeployHubProject / DeployHub-Pro

DeployHub Pro Pipeline Status Project
https://www.openmakesoftware.com/application-release-automation-for-continuous-delivery/
Other
11 stars 4 forks source link

Copy files from windows share location #260

Closed piyush94 closed 5 years ago

piyush94 commented 5 years ago

Pulling files from windows share location, without having to mount it as a filesystem.

CC: @svisagan83

sbtaylor15 commented 5 years ago

Right now the windows share has to be mounted to the DeployHub docker container.

Enhancement is to create a Windows FS repository that will "check out" from the windows share to the drop zone.

sbtaylor15 commented 5 years ago

Use pre-action at the application to pull files from the windows folder to a location in the docker container. Then a file system repository will be used push the files to the end points.

sbtaylor15 commented 5 years ago

@piyush94 Are the files being shared via a Windows Server or another way such as a NAS? If it is a windows server, will there be WinRM access to it?

CC: @svisagan83

piyush94 commented 5 years ago

@sbtaylor15 In most cases it's a Windows Server with a shared location. Regarding WinRM, it comes disabled by default, so we have to go and enable it initially. It will have WinRM access after that.

CC: @svisagan83

sbtaylor15 commented 5 years ago

@piyush94 I believe we have a found solution that will work without the need for WinRM and work directly against the windows share. Testing it out now.

sbtaylor15 commented 5 years ago

@piyush94 here is the setup. Please pull the latest docker image then import the procedure into the GLOBAL Functions & Procedures tree.

export_RunWinShare.zip

Next, setup the Action

runwinshare-action runwinshare-details

Next, setup a Component that uses the Action as a Custom Action. Make this component the first one in the list of Components for the Application Version.

comp-attrs

image

CC: @svisagan83

sbtaylor15 commented 5 years ago

@piyush94 FYI, no WinRM changes are needed.

Also, you can skip the "mount" component and put the Action as a Pre-Action to the Application Version.

piyush94 commented 5 years ago

@sbtaylor15 I am getting this error:

image

image

image

image

image

image

I have created a filesystem repo pointing to the winshare_folder, that as per my understating, will be in the deployhub container, and the above action is supposed to mount the windows share at that location.

image

Let me know if i am missing something.

CC: @svisagan83

sbtaylor15 commented 5 years ago

@piyush94 make sure your WriteEnv2File procedure has the following code at the start. Replace what is there in your proc with this.

  set -g RspFile = ${dropzone.path} + "/env.dat";

    set sname = ${component.name.regsub("[-.; ]","_")};

    eval("using stream \$$sname;");
    eval("set envstream = \$$sname;");

    using stream $envstream {

For the file system repo - set it up as file path = /winshares and mark it as appendable.
For the mount component item attrs set the winshare_folder = share and winshare_sharename = \\USTR-UVM-12271\c$

The files will end up in the container as /winshares/USTR-UVM-12271/c$/share/site.zip so set the IIS component item file path = USTR-UVM-12271/c$/share and pattern = site.zip

CC: @svisagan83

piyush94 commented 5 years ago

@sbtaylor15 Did the above changes but still same error. image

CC: @svisagan83

sbtaylor15 commented 5 years ago

How is the Action setup to run? Pre action to the application or a custom action for a component?

piyush94 commented 5 years ago

Pre action to application.

sbtaylor15 commented 5 years ago

@piyush94 - ok, the component.name is undefined at that level. Change the WriteEnv2File as follows:

  set -g RspFile = ${dropzone.path} + "/env.dat";
    set d = now();
    set sname = "s" + ${d.to_int()};

    eval("using stream \$$sname;");
    eval("set envstream = \$$sname;");
sbtaylor15 commented 5 years ago

@piyush94 also, let me know if you see this error msg in the output. Its inconsistently showing up.

directory_create_or_exist: mkdir failed on directory /var/lib/samba/lock/msg.lock: Permission denied

piyush94 commented 5 years ago

@piyush94 - ok, the component.name is undefined at that level. Change the WriteEnv2File as follows:

  set -g RspFile = ${dropzone.path} + "/env.dat";
    set d = now();
    set sname = "s" + ${d.to_int()};

    eval("using stream \$$sname;");
    eval("set envstream = \$$sname;");

Will this affect ansible playbook action at component level?

sbtaylor15 commented 5 years ago

The stream name needs to be unique and changing it to use the time in seconds will do that. The change is compatible for the actions at the component level.

piyush94 commented 5 years ago

@sbtaylor15 above issue is gone, but a new issue is happening.

  1. I created a new application version from base version to try this feature.
  2. I assigned the environment to the new version as i guess it doesn't inherits environments assigned to base version.
  3. When i am deploying the new application version, the assigned environments list goes empty and i get this error:
    INFO: Starting deployment #265
    --
    INFO: Deploying Application "Deploy_IIS_Site;1" into Environment "IIS_Env"
    Deploying  to
    Syntax error at line 37 of "action WriteEnv2File": Invalid type for for loop - must be string, array or stream
    INFO: Time taken 0.011769 seconds

WriteEnv2File at line 37:

foreach(env: ${server.attributes}) {  
      echo $env + ": " + ${server.attributes[$env]};
    }

CC: @svisagan83

sbtaylor15 commented 5 years ago

@piyush94 - We had to rework the logic a bit due to clashes in the dropzone. We remove the WriteEnv2File in the mount action and replaced it with a get credentials procedure. Then we passed in the variables to the mount proc instead of using a env file to pass them in.

Import the GetWinShareCredentials into the GLOBAL domain. export_GetWinShareCredentials.zip

Then change the RunWinShare Proc as follows: RunWinShareArgs

Next change the MountWinShare Action as follows: mountwinshare winshare_creds runwinshare

At the application attribute level set the following variables and use MountWinShare action as a Pre-Action to the application app-attrs

CC: @svisagan83

sbtaylor15 commented 5 years ago

@piyush94 - also pull the latest image

CC: @svisagan83

piyush94 commented 5 years ago

@sbtaylor15 This one worked to some extent. I was getting the below error: image

Turns out in our case the access to winshares is controlled by Active Directory and we also need to pass the user domain also. ref: https://askubuntu.com/questions/109507/smbclient-getting-nt-status-logon-failure-connecting-to-windows-box

So, i changed the dh2winshare script to accept a user domain variable and it was able to mount the share, but it failed to copy files from the path. image

CC: @svisagan83

piyush94 commented 5 years ago

@sbtaylor15 script changes:

@click.option('--winshare_userdom', help='User domain', required=True)

def main(winshare_user, winshare_pass, winshare_sharename, winshare_folder, winshare_userdom):
    """Main entry point"""

    user = winshare_userdom + "/" + winshare_user + "%" + winshare_pass

CC: @svisagan83

piyush94 commented 5 years ago

INFO: Starting Sequential Deployment of Component IIS_Test_Site;1

INFO: Removing Component IIS_Test_Site from Server inblr-uvm-1118 PLAY [Execute File] **** TASK [Execute File] **** fatal: [inblr-uvm-1118.eu.uis.unisys.com]: FAILED! => {"changed": false, "cmd": "-dellist /tmp/tdm.8589.1.tmp", "msg": "Exception calling \"SearchPath\" with \"1\" argument(s): \"Could not locate the following executable -dellist.exe\"", "rc": 2} to retry, use: --limit @/tmp/tmpabbx7vna/runit.retry PLAY RECAP ***** inblr-uvm-1118.eu.uis.unisys.com : ok=0    changed=0    unreachable=0    failed=1

sbtaylor15 commented 5 years ago

@piyush94 - added the user domain code and resolved the -dellist parameter error. Please pull latest image

CC: @svisagan83