ansible

AnsibleError: template error while templating string: expected token 'end of statement block', got '{'

丶灬走出姿态 提交于 2019-12-24 00:42:54
问题 Getting AnsibleError: template error while templating string: expected token 'end of statement block', got '{' Here is my jinja2 template, can someone help me figure out what is wrong? no service pad service tcp-keepalives-in service tcp-keepalives-out service timestamps debug datetime msec localtime show-timezone service timestamps log datetime msec localtime show-timezone service password-encryption ! hostname {{item.hostname}} ! boot-start-marker boot-end-marker ! logging buffered 32000 no

Ansible: Can't set variable for sequential execution

走远了吗. 提交于 2019-12-24 00:37:58
问题 I'm trying to build a playbook with rolling update use case (Sequential Execution) with the serial element. Since I have to use the serial value in multiple places in the playbook, I wanted to use it as a variable which can be used to define somewhere as a group variable. Inventory file [all] webserver1 ansible_host=10.1.1.1 ansible_user=root webserver2 ansible_host=10.1.1.2 ansible_user=root webserver3 ansible_host=10.1.1.3 ansible_user=root dbserver1 ansible_host=10.1.2.1 ansible_user=root

How to process a command asking for inputs with an Ansible task?

旧街凉风 提交于 2019-12-24 00:23:43
问题 I'm learning Ansible and I'm wondering how to write a task to process the following command: $<command> <options> username: email address: password: password (check): The <command> <option> asks for four variables that can be hardcoded in the playbook. Thank you for any insight you can provide 回答1: Use expect module: - hosts: localhost tasks: - expect: command: command option responses: username: "John Doe" email: "joh@doe.com" password: "mypass" 来源: https://stackoverflow.com/questions

Mac 安装

强颜欢笑 提交于 2019-12-23 23:48:28
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> sql建立数据库 create database opsmanage DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; grant all privileges on opsmanage.* to root@'%' identified by 'password'; 安装依赖 brew install libmagic 配置文件 conf/opsmanage.ini [db] engine = mysql host = 127.0.0.1 port = 3307 user = root password = 123456 database = opsmanage [redis] host = 127.0.0.1 port = 6379 password = ansible_db = 3 celery_db = 4 default_db = 0 [deploy] path = /Users/lijingjing/OpsManage/workspaces 初始化数据 python3 manage.py makemigrations wiki python manage.py createsuperuser # 建立后台管理员帐号 https://github

ansible模块学习

 ̄綄美尐妖づ 提交于 2019-12-23 21:27:37
ansible的功能:   模块化任务,调用特定的模块,完成特定的任务   基于python语言实现,由paramiko、pyyaml和jinja2三个模块构建   部署简单,agentless,ansible基于ssh协议实现的   主从模式   支持自定义模块   支持playbook   允许重复执行 ansible的安装,ansible提供的rpm包在epel源上   note:epel源安装   cd /etc/yum.repos.d   wget http://mirrors.neusoft.edu.cn/epel/epel-release-latest-6.noarch.rpm   rpm -ivh epel-release-latest-6.noarch.rpm   yum install ansible -y ansible主端:192.168.223.136 节点1:192.168.223.146 1、ssh-keygen -t rsa -f ~/.ssh/id_rsa -P '' 2、ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.223.143 3、远程连接ssh root@192.168.223.146或者ssh 192.168.223.146 4、在节点上执行命令 [root@node1 ~]# ssh

How can I break the with_items loop based on a condition

和自甴很熟 提交于 2019-12-23 20:27:33
问题 I want to break out of the with_items loop based on a condition. That condition for arguments sake is if the stdout of a command is equal to a particular string. Obviously the example below does not work but this is an idea of what I want to do. For example: - name: testing loop shell: "echo {{ item }}" with_items: - "one" - "two" - "three" register: shell_command # registering the shell command and it's attributes when: shell_command.stdout == "two" # break once the stdout of the run shell

Using Ansible to execute Powershell DSC

一个人想着一个人 提交于 2019-12-23 20:05:25
问题 My end goal is to configure AdcsCertificationAuthority on a Server 2016 Server using Ansible. - name: Install ADCS with sub features and management tools win_feature: name: Adcs-Cert-Authority state: present include_management_tools: yes register: win_feature - name: reboot if installing Adcs-Cert-Authority feature requires it win_reboot: when: win_feature.reboot_required - name: Add ActiveDirectoryCSDsc win_psmodule: name: ActiveDirectoryCSDsc state: present - name: Configure

Generating tuples variables in ansible templates

╄→гoц情女王★ 提交于 2019-12-23 19:08:16
问题 I'm trying to setup a playbook to deploy an influxdb cluster. Everything works fine except that we use INfluxDB Cluster Client I am generating a production.py file which is read by our script. InfluxdbClusterClient is waiting for a tuple to list all influx servers : 'hosts': [('fr-influxdb-prod-1', 8086), ('fr-influxdb-prod-2', 8086), ('fr-influxdb-prod-3', 8086)], I am trying to generate those tuples from ansible variables but I don't know how to to dat. I tried: / Variables / influxdb_hosts

Provisioning Ubuntu 16.04 Vagrant with Ansible fails on chown

牧云@^-^@ 提交于 2019-12-23 16:23:14
问题 I am trying to provision an Ubuntu Xenial Vagrant guest with Ansible. It worked correctly on Ubuntu 14.04, but fails on 16.04. The error that I get is chown failed: failed to look up user vagrant The task that I am running is the following: - name: Ensure /srv/web exists become: yes file: path: /srv/web state: directory mode: 0755 owner: "{{ remote_user }}" Searching hasn't found much help. Thanks! Edit: Further testing on a Digital Ocean 14.04 droplet also shows this issue. Edit 2: Full

ansible 工作原理以及使用详解

≡放荡痞女 提交于 2019-12-23 13:35:12
内容: 1、ansible的作用以及工作结构 2、ansible的安装以及使用 3、ansible的playbook使用 一、ansible的作用以及工作结构 1、ansible简介: ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能。ansible是基于模块工作的,本身没有批量部署的能力。真正具有批量部署的是ansible所运行的模块,ansible只是提供一种框架。主要包括: (1)、连接插件connection plugins:负责和被监控端实现通信; (2)、host inventory:指定操作的主机,是一个配置文件里面定义监控的主机; (3)、各种模块核心模块、command模块、自定义模块; (4)、借助于插件完成记录日志邮件等功能; (5)、playbook:剧本执行多个任务时,非必需可以让节点一次性运行多个任务。 2、ansible的架构:连接其他主机默认使用ssh协议 二、ansible的安装以及常用模块使用 1、ansible无服务器端,使用时直接运行命令即可,同时不需要在被管控主机上安装任何客户端,因此ansible是一个十分轻量级的工具,可以在epel源进行安装,ansible已经被红帽收购