我试图在Ansible(v2.0)中使用ecs_taskdefinition模块,我想我已经陷入了基本的Ansible YAML陷阱。
根据模块的示例,如果我为memory
和- name: "Create task definition"
ecs_taskdefinition:
containers:
- name: simple-app
cpu: 10
memory: 300
essential: true
image: "httpd:2.4"
portMappings:
- containerPort: 80
hostPort: 80
提供整数值,则按预期工作:
memory
虽然,我希望cpu
和APP_ENV: "test"
test:
containers:
simple_app:
memory: 1920
cpu: 2560
- name: "Create task definition"
ecs_taskdefinition:
containers:
- name: simple-app
cpu: "{{vars.get(APP_ENV).containers.simple_app.cpu | int}}"
memory: "{{vars.get(APP_ENV).containers.simple_app.memory | int}}"
essential: true
image: "httpd:2.4"
portMappings:
- containerPort: 80
hostPort: 80
是可以接受的。这样我就可以在不同的环境中使用相同的容器定义。
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter containerDefinitions[0].memory, value: 1920, type: <type 'str'>, valid types: <type 'int'>, <type 'long'>
Invalid type for parameter containerDefinitions[0].cpu, value: 2560, type: <type 'str'>, valid types: <type 'int'>, <type 'long'>
上面,我从botocore API中得到错误:
const purchasesByDepartment = (state = {}, action) => {
switch (action.type) {
case RECEIVE_POS:
let nextPOS = Object.assign({}, state[action.department] || {}, {
purchaseOrders: action.json
});
return Object.assign({}, state, nextPOS);
default:
return state
}
}
这是否可以修复而无需更新Ansible模块以实际尝试将这些值转换为整数?
答案 0 :(得分:1)
它似乎在Ansible版本2.1.1.0中工作。如果你无法使它工作,一个可能的解决方案是使用const Parent = React.createClass({
getInitialState() {
return {counter: 0, id: 0};
},
handleClick(id) {
if(this.state.id == id){
this.setState({counter: ++this.state.counter, id: id });
} else {
this.setState({counter: 1, id: id });
}
},
getCounter(id){
if(id == this.state.id){
return this.state.counter;
} else {
return 0;
}
},
render() {
const rows = [];
for (let i = 0; i < 3; i++) {
rows.push(<Child key={i} counter={this.getCounter(i)} handleClick={this.handleClick} id={i} />);
}
return (
<ul>
{rows}
</ul>
);
}
});
const Child = React.createClass({
render() {
return (
<div onClick={this.props.handleClick.bind(null, this.props.id)}>
{this.props.counter}
</div>
);
}
});
ReactDOM.render(
<Parent />,
document.getElementById('app')
);
过滤器将变量定义为字典的顶级和不 ...
int
注意:我使用了vars:
APP_ENV: test
simple_app_container_cpu: 2560
simple_app_container_ram: 1920
tasks:
- name: Create task definition
ecs_taskdefinition:
containers:
- name: simple-app
cpu: "{{simple_app_container_cpu}}"
memory: "{{simple_app_container_ram}}"
代替ram
,因为我喜欢它的排列方式:)