我们使用在处理程序上重新启动sshd的用户模块,但这仅在服务器是Ubuntu 16时有效。
我试图像这样骑过它:
- name: Set SSH/SSHD service
include_vars:
ssh_service: "sshd"
when: ( ansible_distribution_version == "16.04" ) and ( ansible_distribution == "Ubuntu" )
- name: Set SSH/SSHD service
include_vars:
ssh_service: "ssh"
when: ( ansible_distribution_version == "14.04" ) and ( ansible_distribution == "Ubuntu" )
但是这会返回有关调试的错误:
fatal: [172.48.0.146]: FAILED! => {"failed": true, "msg": "ssh_service is not a valid option in debug"}
处理程序如下:
- name: restart_sshd
service: name="{{ ssh_service }}"
state=restarted
有一种整洁的方法吗?我不想通过groupvars指定这个。
答案 0 :(得分:-1)
按照:
我没有按设计使用include_vars,它需要一个文件。
我可以改为使用- name: Set SSH/SSHD service
set_fact:
ssh_service: "sshd"
when: ( ansible_distribution_version == "16.04" ) and ( ansible_distribution == "Ubuntu" )
:
public static void CallWebService(string XmlText)
{
try
{
var _url = "https://nodeD1.test.webservices.amadeus.com/1ASIWMLFPNP";// "https://noded1.test.webservices.amadeus.com/1asiwmlfpnp";
var _action = "http://webservices.amadeus.com/fmptbq_14_3_1a";
XmlDocument soapEnvelopeXml = CreateSoapEnvelope(XmlText);
HttpWebRequest webRequest = CreateWebRequest(_url, _action);
webRequest = InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest);
// begin async call to web request.
IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null);
// suspend this thread until call is complete. You might want to
// do something usefull here like update your UI.
asyncResult.AsyncWaitHandle.WaitOne();
// get the response from the completed web request.
string soapResult;
using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))
{
using (StreamReader rd = new StreamReader(webResponse.GetResponseStream()))
{
soapResult = rd.ReadToEnd();
}
Console.Write(soapResult);
}
}
catch (WebException webex)
{
WebResponse errResp = webex.Response;
using (Stream respStream = errResp.GetResponseStream())
{
StreamReader reader = new StreamReader(respStream);
string text = reader.ReadToEnd();
}
}
}
private static HttpWebRequest CreateWebRequest(string url, string action)
{
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Headers.Add("SOAPAction", action);
webRequest.ContentType = "text/xml;charset=\"utf-8\"";
webRequest.Accept = "text/xml";
webRequest.Method = "POST";
return webRequest;
}
private static XmlDocument CreateSoapEnvelope(string XmlText)
{
XmlDocument soapEnvelopeDocument = new XmlDocument();
soapEnvelopeDocument.LoadXml(string.Format(@"{0}",XmlText));
return soapEnvelopeDocument;
}
private static HttpWebRequest InsertSoapEnvelopeIntoWebRequest(XmlDocument soapEnvelopeXml, HttpWebRequest webRequest)
{
using (Stream stream = webRequest.GetRequestStream())
{
soapEnvelopeXml.Save(stream);
return webRequest;
}
}