Ansible从一个target node取值并赋值给所有的target node

Ansible操作三个node,其中有一个pod(app_api_pod_name)运行其中的一个上。
Step 1 需要判断这个pod中有没有存在一个文件,这个地方希望只在第一个node1上执行就可以了,这样其他的node都会skip,
如果是这样skip其他的node的时候,仍然会进行赋值,导致最后的结果是CA_exist无法registe,除了node1,其他node拿到CA_exist都是空值。
所以这个地方就理解了,ansible的所有变量,包括常量和临时变量都是按node进行区分和隔离的,不能共享。

Step 2 就是用来解决这个问题,在其他的node的变量组把这个值给赋值上,关键取值 hostvars[groups[‘role_control’][0]].CA_exist.rc

1
2
3
4
5
6
7
8
9
10
11
12
13

- name: check if CA exist in app-api
become: yes
shell: "kubectl exec -it {{ app_api_pod_name.stdout_lines[0] }} cat /etc/pki/ca-trust/source/anchors/xxxca.pem -n xxxx"
ignore_errors: yes
register: CA_exist
when: "inventory_hostname == groups['role_control'][0] and app_api_pod_name is defined"

- name: set if need to copy CA
set_fact:
need_copy: "{{ hostvars[groups['role_control'][0]].CA_exist.rc }}"
when: "hostvars[groups['role_control'][0]].CA_exist is defined and hostvars[groups['role_control'][0]].CA_exist.rc == 1"

天冷了

感觉突然就天冷了,好像还没准备好,夏天就过去了,秋天也过去了。

供暖费都交了,下个月就开始供暖了。

减肥减的不抗冻了,晚上得穿上秋裤才能出去溜娃。

工作的事情搞的有点糟心,不要乱,相信美好的事情总会发生的。

linux磁盘分区文件系统filesystem损坏后修复

openstack中把volume detach掉后,重新attach回来会有一定概率导致分区无法挂载,手动mount一下后会发现报错filesystem无法识别。
表象可能是lsblk和df显示的磁盘大小不一致。主动指明成ext4后再次mount后,仍然会是失败,这个时候就需要手动恢复一下filesystem了。

  1. 先把磁盘去掉挂载, 以下均以/dev/vdb为例

    1
    # unmount /dev/vdb

    如果失败,则修改/etc/fstab里的记录,注释掉挂载,然后重启OS。

  2. 用fsck检查磁盘

    1
    2
    3
    4
    5
    6
    7
    8
    # e2fsck /dev/vdb
    e2fsck 1.41.12 (17-May-2010)
    Pass 1:Checking inodes, blocks, and sizes
    Pass 2:Checking directory structure
    Pass 3:Checking directory connectivity
    Pass 4:Checking reference counts
    Pass 5:Checking group sumary information
    ext4-1:11/131072 files (0.0% non-contiguous),27050/524128 blocks
  3. 用resize2fs重新恢复一次磁盘filesystem

    1
    2
    3
    4
    # resize2fs /dev/vdb
    resize2fs 1.41.12 (17-May-2010)
    Resizing the filesystem on /dev/vdb to 524128 (1k) blocks.
    The filesystem on /dev/vdb is now 524128 blocks long.
  4. 再次mount回来,检查文件。

    1
    # mount /dev/vdb /data0

转到HEXO了

Jekyll安装主题太麻烦,也许是没找到路子。
Jekyll依赖的Ruby的环境在我本地始终没有配置成功,尝试了好几遍,弃了。

决定试探一下HEXO,基于npm安装的,主题安装比较容易,改起来也挺简单。
唯一的遗憾是Jekyll全部代码push到github,github是可以自动编译的,但是HEXO需要在本地产生静态代码,然后把所有的静态代码push到github里去。
但是整体的效果还是挺满意的,换了。