首页 > 其他分享 >判断语句示例

判断语句示例

时间:2023-01-22 11:11:14浏览次数:40  
标签:语句 username 判断 name 示例 when result user

判断添加用户

- hosts: all
  vars:
  - username: test1
  tasks:
  - name: detect whether the user exists
    shell:
      id {{ username }}
    register: result
    ignore_errors: true
  - name: debug
    debug:
      msg: "{{ username }} exsist,nothing to do"
    when: result.rc == 0
  - name: user add {{ username }}
    user:
      name: "{{ username }}"
      state: present
    when: result.rc != 0

遗留问题,如何通知判断添加多个用户

标签:语句,username,判断,name,示例,when,result,user
From: https://www.cnblogs.com/wangend/p/17064314.html

相关文章

  • 一文解决如何使用 C 语言判断质数(素数)[ 附解析与源码 ]
    前言质数历来都是数学界的宠儿,是数学里神秘的谜团。质数又和C语言有着不解之缘,本篇文章将讲解如何用C语言判断质数。为了方便大家在读完此文章后使用文中程序,我会将......
  • SSM小示例
    SSM=Spring+SpringMVC+MyBatis准备数据库SETFOREIGN_KEY_CHECKS=0;DROPTABLEIFEXISTS`user`;CREATETABLE`user`(`id`int(11)NOTNULLAUTO_INCREM......
  • 判断回文数
    题目:  解法一:将整数转换为字符串python3:classSolution:defisPalindrome(self,x:int)->bool:returnstr(x)==str(x)[::-1]解法二:只需要判......
  • ifelse嵌套屎山的解决方法-卫语句
    卫语句(Guard)什么是卫语?卫语句是一种编程思想,提前检查边界,保卫代码。一、什么时候使用卫语句大厂开发规范,超过三个ifelse建议使用卫语句、策略模式、状态模式等方式重......
  • react table ts 示例
    interfaceColumnDetails{[key:string]:string}constdata=useMemo<ColumnDetails[]>(()=>[{col1:'Hello',col2:'World',},......
  • 【Azure 存储服务】.NET7.0 示例代码之上传大文件到Azure Storage Blob (二)
    问题描述在上一篇博文(【Azure存储服务】.NET7.0示例代码之上传大文件到AzureStorageBlob(一):​​​https://www.cnblogs.com/lulight/p/17061631.html​​)中,介绍了第......
  • 【Azure 存储服务】.NET7.0 示例代码之上传大文件到Azure Storage Blob (二)
    问题描述在上一篇博文(【Azure存储服务】.NET7.0示例代码之上传大文件到AzureStorageBlob(一):https://www.cnblogs.com/lulight/p/17061631.html)中,介绍了第一种分片......
  • 条件控制语句
    if语句包含零个或多个elif子句,及可选的else子句。关键字‘elif‘是‘elseif’的缩写,适用于避免过多的缩进。可以把if…elif…elif…序列看作是其他语言中......
  • 循环控制语句 之 with_together
    功能类似于:列表元素数量上要一一对应foriinzip([1,2,3],['a','b','c']):print(i)-hosts:alltasks:-name:debugdebug:msg:"{{item}}"......
  • 循环控制语句 之 with_indexed_items
    添加索引-hosts:alltasks:-name:debugdebug:msg:"{{item}}"with_indexed_items:-[1,2,3]-['a','b','c','d']-hosts:all......