AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-579170

Maxime's questions

Martin Hope
Maxime
Asked: 2021-12-11 11:41:44 +0800 CST

Ansible blockinfile 模块 - 插入插入代码行

  • 0

我尝试使用 Ansible blockinfile模块插入代码行(shell 脚本)。

name: Customized prompt
blockinfile:
path: /etc/profile.d/customized_prompt.sh
create: yes
block: |

#!/bin/bash

# customized prompt normal user and root

if (( "$(id -u)" == "1000" ))
then
    PS1="[\u@\H \w]$ "
elif (( "$(id -u)" == "0" ))
then
    PS1="[\u@\H \w]# "
fi

我有这个 Ansible 错误

[admin@srvansible /etc/ansible]$ ansible-playbook playbook_prompt.yml --ask-become-pass
BECOME password: 
ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
could not find expected ':'

The error appears to be in '/etc/ansible/roles/utilities/tasks/main.yml': line 14, column 4, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

if (( "$(id -u)" == "1000" ))
then
^ here

我需要帮助:)

谢谢你

ansible ansible-playbook shell-scripting
  • 1 个回答
  • 295 Views
Martin Hope
Maxime
Asked: 2021-02-15 07:14:59 +0800 CST

Bash脚本 - 检查一个变量是否位于其他两个变量之间?

  • 1

在 Bash 脚本中,我想检查 var1 是否位于 var2 和 var3 之间。但我找不到该怎么做。

像这样的东西。

var1=15
var2=10
var3=20

if [ "$var1" is located beetween "$var2" and "$var3" ]
then
    echo "ok"
else
    echo "not ok"
fi

你能帮我吗 ?

谢谢你。

linux bash variables shell-scripting conditional
  • 2 个回答
  • 286 Views
Martin Hope
Maxime
Asked: 2020-07-24 12:13:45 +0800 CST

linux bash脚本 - 如何检查变量是否已更改?

  • 2

我编写了一个小 bash 脚本,它检查可用的最新稳定 Nextcloud 服务器版本并通知我

我希望脚本仅在服务器版本号更改时才使用“notify-send”命令通知我。

我的简单脚本:

#!/bin/bash

# The latest stable version of Nextcloud server in a variable

LatestStableVersion=$(curl -s https://nextcloud.com/install/ | grep 'Latest stable version:' |  awk '{print $18}')


# Notify latest stable version of Nextcloud server

notify-send -u critical -t 12000 "Nextcloud" "New version available : $LatestStableVersion"

仅当“$LatestStableVersion”变量中的服务器编号版本更改时,我才需要通知。我想用“while”循环。

你知道怎么做吗?

谢谢

linux scripting bash nextcloud
  • 1 个回答
  • 715 Views
Martin Hope
Maxime
Asked: 2020-06-17 08:26:41 +0800 CST

如何在 Fedora 32 Server 虚拟机上使用 Ansible 安装 RPM Fusion 存储库?

  • 2

我想用 Ansible 在 Fedora 32 Server 虚拟机上安装 RPM Fusion 存储库

我尝试了各种可能性均未成功:

- name: Enable the RPM Fusion repository
command: dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-    free-release-$(rpm -E %fedora).noarch.rpm
when: ansible_facts['os_family'] == 'Fedora' and ansible_facts['distribution_major_version'] == '32'

或者

- name: Enable the RPM Fusion repository
  dnf:
    name: 'https://download1.rpmfusion.org/free/fedora/rpmfusion-    free-release-$(rpm -E %fedora).noarch.rpm'
    state: present
  when: ansible_facts['os_family'] == 'Fedora' and ansible_facts['distribution_major_version'] == '32'

每次跳过任务

TASK [Enable the RPM Fusion repository] *******************************************************************************
skipping: [my-ip-address]

你有想法吗?

谢谢!

rpm fedora ansible ansible-playbook repository
  • 1 个回答
  • 1353 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve