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-1079580

Konstantin's questions

Martin Hope
Konstantin
Asked: 2024-04-05 20:15:55 +0800 CST

为什么 debian 中的自动完成 Journalctl 不起作用?

  • 5

我在 CentOS 中输入命令:

sudo journalctl -xe --unit ss

之后,我按下 Tab 并在控制台中看到:

sudo journalctl -xe --unit sshd.service

我在 Debian 中输入命令:

sudo journalctl -xe --unit ss

之后,我按下 Tab 键......什么也没有发生:

sudo journalctl -xe --unit ss

为什么自动完成 Journalctl 在 Debian 中不起作用?

journalctl
  • 1 个回答
  • 132 Views
Martin Hope
Konstantin
Asked: 2024-03-22 00:50:43 +0800 CST

为 Prometheus 创建配置文件

  • 5

库存文件(inventories/test/environments/tmp6.yml):

test:
  children:
    environments:
      children:
        tmp6:

tmp6:
  vars:
    ansible_user: superuser
    ansible_password: superuser
    ansible_become_password: "{{ ansible_password }}"
  children:
    infra:
      hosts:
        host_5:
          ansible_host: 192.168.1.72
        host_6:
          ansible_host: 192.168.1.83
    tools:
      hosts:
        host_7:
          ansible_host: 192.168.1.239
        host_8:
          ansible_host: 192.168.1.46

一般的playbook.yml:

- hosts: environments
  roles:
    - role: host-configuration
    - role: host-users
    - role: node-exporter
  post_tasks:
    - ansible.builtin.copy:
        content: |
          - target: 
              - {{ ansible_host }}:9100
            labels:
              environment_name: {{ inventory_file | ansible.builtin.basename | ansible.builtin.regex_replace('.yml$', '') }}
              environment_type: {{ inventory_file | ansible.builtin.dirname | ansible.builtin.dirname | ansible.builtin.basename }}
        dest: "./{{ inventory_file | ansible.builtin.basename }}"
      delegate_to: localhost

在节点上成功安装node_exporter后,需要创建环境的通用配置文件:

- target:
    - 192.168.1.72:9100
    - 192.168.1.83:9100
    - 192.168.1.239:9100
    - 192.168.1.46:9100
  labels:
    environment_name: tmp6
    environment_type: test

主要问题是制定目标清单。

如果创建这样一个模板:

- target: 
    - {{ ansible_host }}:9100
  labels:
    environment_name: {{ inventory_file | ansible.builtin.basename | ansible.builtin.regex_replace('.yml$', '') }}
    environment_type: {{ inventory_file | ansible.builtin.dirname | ansible.builtin.dirname | ansible.builtin.basename }}

变量的值ansible_host总是在变化。因此这不是一个解决方案。

如何在剧本中创建动态主机列表?

PS:Playbook可以应用于多种环境:

ansible-playbook playbook.yml -i inventories/test -l tmp1,tmp3,tmp6

一般任务:

  1. 在“环境”组的节点上安装node_exporter
  2. 在本地主机上创建通用配置文件
  3. 将配置文件复制到主机“prometheus”
ansible
  • 2 个回答
  • 120 Views
Martin Hope
Konstantin
Asked: 2024-03-21 01:38:01 +0800 CST

创建多对元素的字典

  • 6

目录下有文件:

environment1_--_192.168.12.239
environment1_--_192.168.12.46
environment1_--_192.168.12.72
environment1_--_192.168.12.83
environment2_--_192.168.12.150
environment2_--_192.168.12.53
environment2_--_192.168.12.44
environment2_--_192.168.12.90

查找文件:

- ansible.builtin.find:
    paths: "./environments/"
    file_type: file
  register: environment_hosts_files

我需要获取字典列表:

environment_hosts:
  - name: environment1
    hosts:
      - 192.168.12.239
      - 192.168.12.46
      - 192.168.12.72
      - 192.168.12.83
  - name: environment2
    hosts:
      - 192.168.12.150
      - 192.168.12.53
      - 192.168.12.44
      - 192.168.12.90

这个怎么做?

ansible
  • 1 个回答
  • 34 Views
Martin Hope
Konstantin
Asked: 2024-03-17 18:03:22 +0800 CST

文件或目录所在的设备

  • 6

如何识别文件或目录所在的设备?

有一个统计模块。
结果中有一个“设备 inode 驻留”。

如何将“inode 所在的设备”映射到分区?

ansible
  • 2 个回答
  • 84 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