Ansible playbook可以--key-file
在命令行中指定用于ssh连接的密钥.
ansible-playbook -i hosts playbook.yml --key-file "~/.ssh/mykey.pem"
Run Code Online (Sandbox Code Playgroud)
是否可以在playbook文件中指定此键的位置而不是--key-file
在命令行上使用?
因为我想将这个键的位置写入一个var.yaml
文件,该文件将由ansible playbook读取vars_files:
.
以下是我配置的一部分:
vars.yml文件
key1: ~/.ssh/mykey1.pem
key2: ~/.ssh/mykey2.pem
Run Code Online (Sandbox Code Playgroud)
playbook.yml文件
---
- hosts: myHost
remote_user: ubuntu
key_file: {{ key1 }} # This is not a valid syntax in ansible. Does there exist this kind of directive which allows me to specify the ssh key used for this connection?
vars_files:
- vars.yml
tasks:
- name: Echo a hello message
command: echo hello
Run Code Online (Sandbox Code Playgroud)
我试过添加ansible_ssh_private_key_file
下 …
我想搜索以"abc"开头并以vim中的"xyz"结尾的字符串.
以下是我尝试过的命令:
:1,$g/abc[\w\W]*xyz/
:1,$g/abc\[\\w\\W\]\*xyz/
:1,$g/abc*xyz/
Run Code Online (Sandbox Code Playgroud)
"[\ w\W]*"表示"abc"和"xyz"之间的文本可以是任何字符
"1,$"表示搜索范围是由vim打开的文件中的第1行到最后一行.
我发现了搜索模式
abc[\w\W]*xyz
Run Code Online (Sandbox Code Playgroud)
为什么它在vim中失败?
我想写一个*.sh脚本来执行多个MySQL命令.
目前,我能做的就是以下内容
mysql -h$host -u$user -p$password -e "drop database $dbname;"
mysql -h$host -u$user -p$password -e "create database $dbname;"
mysql -h$host -u$user -p$password -e "another MySQL command"
...
Run Code Online (Sandbox Code Playgroud)
有没有办法避免每次我想执行MySQL命令时键入"mysql -h $ host -u $ user -p $ password -e"?
我正在使用Jenkins PowerShell插件来构建项目.
但是,我发现Jenkins总是认为我的构建成功,无论我在Windows PowerShell
命令内输入什么.
这是一个例子:
如您所见,asdf
这不是一个合法的命令.詹金斯应该FAILURE
在构建之后给我.
但控制台输出给了我:
Started by user admin
Building in workspace C:\Users\Administrator\.jenkins\jobs\Test\workspace
[workspace] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& 'C:\Users\ADMINI~1\AppData\Local\Temp\hudson2092642221832331776.ps1'"
The term 'asdf' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\ADMINI~1\AppData\Local\Temp\hudson2092642221832331776.ps1:1 char:5
+ asdf <<<<
+ CategoryInfo : ObjectNotFound: (asdf:String) [], …
Run Code Online (Sandbox Code Playgroud) 我一直对你如何在数据库中抛出一些SQL感兴趣,它几乎立即以有序的方式返回你的结果,而不用把它当作黑盒子之外的任何东西.
真的发生了什么?
我很确定它与值如何在内存中定期布局有关,类似于数组; 但除此之外,我不知道其他什么.
如何以一种方式解析SQL以促进所有这些?
我有这样的代码:
#!/bin/bash
COLOR_REST='\e[0m'
COLOR_GREEN='\e[0;32m'
echo -e "${COLOR_GREEN}OK${COLOR_REST}"
Run Code Online (Sandbox Code Playgroud)
当我将代码复制并粘贴到 iTerm 中时,它OK
以绿色显示。
但是,当我将代码存储在名为 的文件中testColor.sh
并执行./testColor.sh
. 它显示\e[0;32mOK\e[0m
在我的屏幕上。
为什么不显示OK
绿色?
我也尝试过bash testColor.sh
,并且sh testColor.sh
。两者都无法以绿色显示文本。
-e
另一件我觉得奇怪的事情是,我在 .bsd 通用命令手册中没有看到该选项man echo
。
我使用 macOS High Sierra 作为我的操作系统。
sg-d578d9ab
我想删除我的 AWS 账户中的安全组。
当我尝试删除它时收到以下消息。
这些安全组与一个或多个网络接口关联。删除网络接口,或将它们与不同的安全组关联。查看您的网络接口。
为了解决问题,我打开网络接口页面查看正在使用哪个网络接口sg-d578d9ab
。
事实证明,有 1 个网络接口正在使用该安全组。
然后,我使用“更改安全组”选项将安全组与网络接口解除关联。
然后我收到一条消息说
您没有访问指定资源的权限。
为什么我无法更改网络接口的安全组?
我的AWS账户有AdministratorAccess
权限。
网络接口的Attachment owner
和属性是。这似乎是我无法更改其安全组的原因。Owner ID
amazon-rds
这是否意味着网络接口是在其他人设置 AWS RDS 时创建的?
我尝试使用setFillForegroundColor和setFillBackgroundColor来更改excel文件的单元格颜色.
但是,我失败了,我真的不知道问题是什么.我用Google搜索了好几个小时,仍然无法找到正确的方法来设置颜色.
以下是我写的代码:
import java.awt.Color;
import java.io.File;
import java.io.FileOutputStream;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class TestColor {
public static void main(String[] args) {
File f = new File("test.xlsx");
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
XSSFRow row = sheet.createRow(0);
XSSFCell cell = row.createCell(0);
cell.setCellValue("no blue");
// set the color of the cell
XSSFCellStyle style = wb.createCellStyle();
XSSFColor myColor = new XSSFColor(Color.BLUE);
style.setFillForegroundColor(myColor);
style.setFillBackgroundColor(myColor);
cell.setCellStyle(style); // this command seems to fail …
Run Code Online (Sandbox Code Playgroud) 我编写了一个简单的程序,并使用jconsole.exe来监视其堆大小.
public class HeapTest {
public static void main(String[] args) {
while(true) {
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是结果
我不明白为什么堆大小不断增长.我的程序中没有new()任何Object.
我的程序中使用的堆是多少?
我没有向jconsole.exe添加任何其他参数; 只需双击它,然后根据PID加载java进程.
环境:Windows 7下的Java 1.8.0_25
在Cloudwatch事件的结构中:
'events': [
{
'logStreamName': 'string',
'timestamp': 123,
'message': 'string',
'ingestionTime': 123,
'eventId': 'string'
},
]
Run Code Online (Sandbox Code Playgroud)
摄入时间是什么意思?
他们在这份文件中说:
ingestionTime
Run Code Online (Sandbox Code Playgroud)The time the event was ingested.
我发现仍然不清楚.