AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-760148

Manu's questions

Martin Hope
Manu
Asked: 2022-08-17 03:18:03 +0800 CST

在以下循环任务中使用任务中的变量

  • 0

我想跨多个服务器上的多个 MSSQL 实例部署一些存储过程。在我的剧本中,我有一个任务收集服务器上的所有实例,我在以下任务中使用它来循环任何实例上的所有内容。我在我的许多剧本中都使用了这种方法,但在这个剧本中,我还需要能够when在循环任务时在条件中使用先前收集的变量。

这些是我的剧本的相关部分:

#################### GATHER INSTANCES ####################
    - name: list instances
      win_shell: (Find-DbaInstance -ComputerName localhost | Where Availability -eq 'Available').instancename
      changed_when: False
      register: sql_instances

#################### GATHER PROCEDURES ####################
    - name: list procedures
      win_shell: (Get-DbaDbStoredProcedure -SqlInstance localhost\{{ item }} -Database master -Schema dbo).Name
      changed_when: False
      register: sql_procedures
      loop: "{{ sql_instances.stdout_lines }}"  
      
#################### INSTALL CUSTOM PROCEDURES ####################
    - name: my_procedure
      ansible.windows.win_powershell: 
        script: |
          $batch_install_prodecure = @'
            --My Stored Procedure
          '@
          Invoke-DbaQuery -SqlInstance localhost\{{ item }} -Query $batch_install_prodecure
      when: sql_procedures.stdout_lines.find('my_procedure') != 0
      register: my_procedure
      loop: "{{ sql_instances.stdout_lines }}" 

这是输出:

#################### GATHER INSTANCES ####################
  "stdout_lines": [
    "MSSQLSERVER2",
    "MSSQLSERVER"
  ]
  
 #################### GATHER PROCEDURES ####################
   "stdout_lines": [
    "sp_Something",
    "sp_Somethingelse"
  ],
  "stderr_lines": [],
  "_ansible_no_log": false,
  "item": "MSSQLSERVER2",
  "ansible_loop_var": "item",
  "_ansible_item_label": "MSSQLSERVER2"
}
############################
  "stdout_lines": [
    "sp_Something",
    "sp_Somethingelse"
  ],
  "stderr_lines": [],
  "_ansible_no_log": false,
  "item": "MSSQLSERVER",
  "ansible_loop_var": "item",
  "_ansible_item_label": "MSSQLSERVER"
}

#################### INSTALL CUSTOM PROCEDURES ####################
The conditional check 'sql_procedures.stdout_lines.find('custProc_Backupcheck') != 0' failed. The error was: error while evaluating conditional (sql_procedures.stdout_lines.find('custProc_Backupcheck') != 0): 'dict object' has no attribute 'stdout_lines'

我有点明白为什么它不起作用。我必须以某种方式描述找到变量的项,因为它是在循环中生成的。我只是不知道该怎么做。

到目前为止,我所做的最远的是尝试实现与本文中所做的类似的事情,但我想这种方法不适用于我的情况

我知道我可以直接在 PowerShell 中轻松完成所有这些工作,但最终我的目标是安装多个程序(每个任务一个),并且还能够轻松删除旧程序,以便在我的 MSSQL 实例上保持相同的程序清单。

有人可以告诉我如何设置when条件来实现我的目标吗?

编辑:

请参阅接受的答案,了解为什么它不起作用。

我现在更改为在 PowerShell 中检查是否已安装该程序:

#################### INSTALL CUSTOM PROCEDURES ####################
    - name: my_procedure
      ansible.windows.win_powershell: 
        script: |
          $name_procedure = 'my_procedure'
          $install_prodecure = @'
            --My Stored Procedure
          '@
          if ((Get-DbaDbStoredProcedure -SqlInstance localhost\{{ item }}  -Database master -Schema dbo).Name -contains $name_procedure) {
              write-host "OK: SP $name_procedure is already installed"
          } else {
              write-host "SET: SP $name_procedure needs to be installed"
              Invoke-DbaQuery -SqlInstance localhost\{{ item }} -Query $install_prodecure
              if ((Get-DbaDbStoredProcedure -SqlInstance localhost\{{ item }}  -Database master -Schema dbo).Name -contains $name_procedure) {
              write-host "OK: SP $name_procedure sucessfully installed"
              } else {
                  write-host "ERROR: Was not able to install $name_procedure"
              }
          }
      register: my_procedure
      loop: "{{ sql_instances.stdout_lines }}" 
      failed_when: my_procedure.host_out.find('ERROR:') != -1
      changed_when: my_procedure.host_out.find('SET:') != -1
sql-server
  • 0 个回答
  • 47 Views
Martin Hope
Manu
Asked: 2021-06-29 05:27:13 +0800 CST

Apache Guacamole 使用来自 DomainA 的用户登录,从 DomainB 到服务器的 rdp

  • 1

概述

我们使用来自 DomainA 的用户登录 Gucamole,在此我们从 DomainB 选择到服务器的 rdp 连接。

信托

DomainA 到 DomainB,反之亦然:

  • 类型:外部
  • Kerberos AES 加密支持:否
  • 方向:双向
  • 传递性:无
  • 身份验证:域范围

权限

来自 DomainA 的用户已加入来自 DomainB 的服务器上的本地远程桌面用户组。暂时也试过用本地Administrators组。

鳄梨

整个设置不是由我完成的,因为它是由另一个团队管理的,所以我没有太多的洞察力。我所知道的是,它适用于从 DomainA 到来自 DomainA 的服务器的用户。用户使用 upn 登录并使用 OpenOTP 的 2FA。如果你们认为分享一些鳄梨酱的配置会有所帮助,请告诉我你们想看什么,我会与团队核实。

鳄梨酱的连接

  • 协议:rdp
  • 主机名:来自DomainB的服务器IP
  • 端口:3389
  • 用户名:${GUAC_USERNAME}
  • 密码:${GUAC_PASSWORD}
  • 域:空白
  • 安全模式:NLA
  • 禁用身份验证:否
  • 忽略服务器证书:是
  • 其他一切都设置为默认值/未配置

当然,我们尝试过多种不同的设置。

症状

现在这就是发生的事情。

  • 我使用来自 DomainA 的用户登录鳄梨酱
  • 接收 OpenOTP 推送并确认
  • 我登录到 Guacamole 并选择连接到 DomainB 的服务器
  • 收到错误信息:

远程桌面服务器当前无法访问。如果问题仍然存在,请通知您的系统管理员,或检查您的系统日志。

  • 重试几次后,我有时会收到以下消息:

此连接已关闭,因为服务器响应时间过长。这通常是由网络问题引起的,例如无线信号不稳定或网络速度慢。请检查您的网络连接并重试或联系您的系统管理员。

  • 现在是让我发疯的有趣部分:我可以通过直接 rdp 使用来自 DomainA 的用户登录到 DomainB 的服务器,如果这样做,请保持连接打开并在 Guacamole 上启动连接,我能够接管会议!

日志

鳄梨酱日志显示绝对没有任何用处。

Windows 安全日志在登录错误时显示此事件:

EventID 4625, Logon
An account failed to log on.

Subject:
    Security ID:        NULL SID
    Account Name:       -
    Account Domain:     -
    Logon ID:       0x0

Logon Type:         3

Account For Which Logon Failed:
    Security ID:        NULL SID
    Account Name:       User (correct)
    Account Domain:     DomainA (correct)

Failure Information:
    Failure Reason:     An Error occured during Logon.
    Status:         0xC000005E
    Sub Status:     0x0

Process Information:
    Caller Process ID:  0x0
    Caller Process Name:    -

Network Information:
    Workstation Name:   f7054e3b9dd7
    Source Network Address: Guacamole-Server-IP
    Source Port:        0

Detailed Authentication Information:
    Logon Process:      NtLmSsp 
    Authentication Package: NTLM
    Transited Services: -
    Package Name (NTLM only):   -
    Key Length:     0

This event is generated when a logon request fails. It is generated on the computer where access was attempted.

The Subject fields indicate the account on the local system which requested the logon. This is most commonly a service such as the Server service, or a local process such as Winlogon.exe or Services.exe.

The Logon Type field indicates the kind of logon that was requested. The most common types are 2 (interactive) and 3 (network).

The Process Information fields indicate which account and process on the system requested the logon.

The Network Information fields indicate where a remote logon request originated. Workstation name is not always available and may be left blank in some cases.

The authentication information fields provide detailed information about this specific logon request.
    - Transited services indicate which intermediate services have participated in this logon request.
    - Package name indicates which sub-protocol was used among the NTLM protocols.
    - Key length indicates the length of the generated session key. This will be 0 if no session key was requested.

故障排除

现在在这一点上,我不知道在哪里设置我的下一个焦点。我们在 Guacamole rdp 连接上尝试了多种设置。在网上做了很多研究,但找不到有人尝试和我们做同样事情的信息示例。由于常规 rdp 工作正常,我们认为我们的信任和权限应该没问题。

你们能给我任何提示我应该调查哪个方向吗?

有人在类似的设置中使用鳄梨酱吗?

编辑 用户 Swisstone 建议的其他事件查看器信息:

RemoteDesktopServices-RdpCoreTS
08:38:23 Info: The server accepted a new TCP connection from client *Guacamole-IP*:53494.
08:38:23 Info: Connection RDP-Tcp#78 created 
08:38:23 Info: Interface method called: PrepareForAccept
08:38:23 Info: Interface method called: SendPolicyData
08:38:23 Info: PerfCounter session started with instance ID 78
08:38:23 Warning: TCP socket was gracefully terminated
08:38:23 Info: Interface method called: OnDisconnected
08:38:23 Info: The server has terminated main RDP connection with the client.
08:38:23 Info: During this connection, server has not sent data or graphics update for 0 seconds (Idle1: 0, Idle2: 0).
08:38:23 Info: Channel rdpinpt has been closed between the server and the client on transport tunnel: 0.
08:38:23 Info: Channel rdpcmd has been closed between the server and the client on transport tunnel: 0.
08:38:23 Info: Channel rdplic has been closed between the server and the client on transport tunnel: 0.
08:38:23 Info: The disconnect reason is 14

TerminalServices-LocalSessionManager
nothing during this time

TerminalServices-RemoteConnectionManager
nothing during this time

忘了说了,Server是2019 Version 1809

编辑2

好的,我现在通过将连接上的安全模式更改为 tls. 我记得之前尝试过 tls 时它不起作用。也许我在整个故障排除过程中所做的一些更改产生了影响。到现在我也说不清那是什么。

在我发现 guacamole 将它用于 rdp 连接之后,我通过随机尝试使用 freerdp 连接的不同选项来得出这个“解决方案”。

在这种情况下,有人认为使用 tls 而不是 nla 有什么顾虑吗?

windows active-directory remote-access apache-2.4 trust-relationship
  • 1 个回答
  • 2167 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve